0

I'm confused with rsync's exclude.

I'm trying to backup every starting with / but exclude /media/ /mnt/ /home/files/ and /home/backup

sudo rsync -a \
       --progress \
       --stats \
       --exclude-from=/home/files/ \
       --exclude-from=/media/ \
       --exclude-from=/mnt/ \
       --exclude-from=/home/backup/ \
   / /home/backup

Won't work.

I end up copying files to /home/backup/home/backup/... I read that I have to write my excludes relative to my transfer root, but i guess if / is my transfer root then /media/ should be relative to that right?

4
man rsync

--exclude=PATTERN       exclude files matching PATTERN
--exclude-from=FILE     read exclude patterns from FILE

exclude-from is used to point to a file that lists the folders that you don't want. Try the option --exclude

0

Your syntax is incorrect; that's why it isnt't working.

You say:

--exclude-from=/home/backup/

when you should simply say

--exclude="/home/backup/*"

Also, you are not using the

--delete-excluded 

switch that can synchronize the directories.

As to your question at the end: Yes, in your case you are specifying / as your beginning for the rsync. So if you exclude "tmp/*" then it is indeed relative to / so it is the same as specifying "/tmp/*"

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.