0

I'm confused about how rsync includes/excludes files and directories. I have an exclude file:

/home/pi/rsync-exclude.txt

with contents:

/proc/*
/sys/*
/dev/*
/boot/*
/tmp/*
/run/*
/mnt/*
/media/*

.Trashes
._.Trashes
.fseventsd
.Spotlight-V100
.DS_Store
.AppleDesktop
.AppleDB
Network Trash Folder
Temporary Items

.bash_history
/etc/fake-hwclock.data
/var/lib/rpimonitor/stat/

and I'm using the following syntax for rsync:

sudo rsync -avH --delete-during --delete-excluded --exclude-from=/home/pi/rsync-exclude.txt / /mnt/

but rsync is creating the directories /mnt/proc, /mnt/sys, etc. They're empty as they should be but I'd prefer if they weren't there at all.

Is there a different syntax I can use to cause rsync to ignore the directories entirely?

3

Your expressions exclude the contents of the directories (/foo/*), not the directories themselves (/proc). For example:

$ mkdir -p foo/{1..3}/{1..3}
$ cat exclude.txt 
/1/*
/2
$ rsync -avH --exclude-from=exclude.txt foo/ bar
sending incremental file list
created directory bar
./
1/
3/
3/1/
3/2/
3/3/

sent 296 bytes  received 89 bytes  770.00 bytes/sec
total size is 0  speedup is 0.00

As can be seen, simply using the directory path is enough to exclude it and all its contents. Oddly enough, you have used this at the end of your exclude list:

/var/lib/rpimonitor/stat/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.