rsync/rsnapshot and exlude/include directory, absolute path

0

I am using rsnapshot and I want to exclude a directory by absolute path.

I added to rsnapshot.conf exclude /home/user/data rsnapshot will use this rsync command:

/usr/bin/rsync -a --delete --numeric-ids --relative --delete-excluded \
    --exclude=/home/user/data /home \
    /backupdir/hourly.0/localhost/

and it works, it excludes the /home/user/data dir but it's not clear to me why it works. Reading the man pages of rsync (and for example this answer https://askubuntu.com/a/349625) exclude/include patterns that start with / are are anchored to the root of transfer, so I was thinking it will fail because it try to exclude

/home/home/user/data

Can someone clarify me this point?
What is the right way to exclude a directory using absolute path?

Thanks for the help

res1

Posted 2017-06-15T11:52:54.487

Reputation: 344

Answers

0

I know this is old, but just for the record...

The --exclude specifies a pattern, not a location in the directory tree "/home". rsync will not add anything to that pattern. so "/home" is not added/duplicated because you have specified --relative.

if you add -iv to your rsync command, rsync will list all Dirs and files in "/home" that it will process. You will note that any directory item with "/home/user/data" in it will be hidden because of the exclude pattern "/home/user/data/"

if you used --exclude=data, then all dir items with "data" in their name will be omitted. so for example, /home/user/data,or /home/user2/data, or /home/user3/data, will be omitted as well. since all have the pattern "data" in them.

Fawzi Masri

Posted 2017-06-15T11:52:54.487

Reputation: 35