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


with contents:


Network Trash Folder
Temporary Items


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?


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 
$ rsync -avH --exclude-from=exclude.txt foo/ bar
sending incremental file list
created directory bar

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:


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.