0

I've had a command in a script which I used a lot for a couple years. I didn't use the script for the last year, but today I ran it again. I'm suddenly having trouble excluding files from an rsync though.

I'm on Ubuntu 18.04 (rsync version 3.1.2) and I run the following command:

rsync -exclude-from='sync_exclude.txt' -azvv -e ssh '.' root@146.xx.xx.xx:~/wp

where the sync_exclude.txt file looks like this:

$ cat sync_exclude.txt
.idea
.git
.gitignore
.DS_Store
sync_exclude.txt
ansible/*
.env

But to my surprise the rsync now also syncs all the things in this exclude file.

I've tried other variations, such as

rsync -exclude=.git/ -azvv -e ssh '.' root@146.xx.xx.xx:~/wp
rsync -exclude=".git/" -azvv -e ssh '.' root@146.xx.xx.xx:~/wp
rsync -exclude=/.git/ -azvv -e ssh '.' root@146.xx.xx.xx:~/wp
rsync -exclude=/.git/* -azvv -e ssh '.' root@146.xx.xx.xx:~/wp
rsync -exclude /.git/ -azvv -e ssh '.' root@146.xx.xx.xx:~/wp
rsync -exclude /.git/* -azvv -e ssh '.' root@146.xx.xx.xx:~/wp
rsync -exclude="/.git/*" -azvv -e ssh '.' root@146.xx.xx.xx:~/wp
rsync -exclude "/.git/*" -azvv -e ssh '.' root@146.xx.xx.xx:~/wp
rsync -exclude={.git/,"ansible/*"} -azvv -e ssh '.' root@146.xx.xx.xx:~/wp
rsync -exclude {.git/,"ansible/*"} -azvv -e ssh '.' root@146.xx.xx.xx:~/wp
etc.

But none of them exclude the .git/ or the ansible/ folder. I've also tried on MacOS, but I have the same problem there.

I'm banging my head against the wall why none of this would suddenly work anymore.

Could anybody help me out of my misery?

1

This might just be a typo, but you have to use --exclude-from instead of -exclude-from (notice the double hyphen there).

1
  • Same for --exclude – PiedPiper Jan 23 '19 at 11:41
0

I couldn't add comment. I think you should add relative path to the file sync_exclude.txt. Example:

rsync --exclude-from='/path-relative/sync_exclude.txt' -azvv -e ssh '.' root@146.xx.xx.xx:~/wp

If that doesn't work try this (add --relative option):

rsync --relative --exclude-from='/path-relative/sync_exclude.txt' -azvv -e ssh '.' root@146.xx.xx.xx:~/wp

and also try changing this to relative path:

$ cat sync_exclude.txt

/path-relative/.idea
/path-relative/.git
/path-relative/.gitignore
/path-relative/.DS_Store
/path-relative/sync_exclude.txt
/path-relative/ansible/*
/path-relative/.env

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.