You are not logged in.

#1 2017-10-10 10:16:58

lnx
Member
Registered: 2009-11-04
Posts: 101

[SOLVED] How to exclude directories when using rsync?

I wanted to copy my home directory to an external HD. But there wasn't enough space. A while ago I used luckyBackup to make a backup which uses rsync. I want to do it from the command line now. But I can't figure out how to exclude a directory. The directory I want to exclude keeps being copied.

To figure it out I have been using the Downloads directory in my home directory because it takes to long to copy my home directory. I'm trying to exclude a directory named 'aurget' in the Downloads directory.
According to different websites I used the following commands:

rsync -ah --progress --exclude 'Downloads/aurget' Downloads/ mnt/extHD/backup
rsync -ah --progress --exclude=Downloads/aurget Downloads/ mnt/extHD/backup
rsync -ah --progress --exclude="Downloads/aurget" Downloads/ mnt/extHD/backup
rsync -ah --progress --exclude="Downloads/aurget/*" Downloads/ mnt/extHD/backup
rsync -ah --progress --exclude=/Downloads/aurget Downloads/ mnt/extHD/backup
rsync -ah --progress --exclude=/Downloads/aurget/ Downloads/ mnt/extHD/backup

Every time the Downloads directory is copied with the aurget directory.

Because I couldn't figure it out I reinstalled luckyBackup. I hoped I could learn from the generated command what I was doing wrong. But the result was the same: aurget is not excluded.

rsync -h --progress --stats -r -tgo -p -l -D --update --exclude=/Downloads/aurget/ /home/my_home/Downloads/ /home/my_home/mnt/extHD/backup

So, I hope someone can tell me what I'm doing wrong.

Last edited by lnx (2017-10-10 21:50:27)

Offline

#2 2017-10-10 10:58:51

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: [SOLVED] How to exclude directories when using rsync?

Patterns are relative to the transfer root - your excludes are telling rsync to exclude Downloads/Downloads/aurget and I'm guessing there is no such directory.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2017-10-10 21:49:29

lnx
Member
Registered: 2009-11-04
Posts: 101

Re: [SOLVED] How to exclude directories when using rsync?

Thank you, Trilby, it solved my problem. But apparently this means that luckyBackup makes the same mistake!?

Offline

#4 2017-10-10 22:00:48

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [SOLVED] How to exclude directories when using rsync?

It's not a mistake, it's expected behaviour.

The mistake is not reading the documentation.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

Board footer

Powered by FluxBB