1

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 '.' [email protected]:~/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 '.' [email protected]:~/wp
rsync -exclude=".git/" -azvv -e ssh '.' [email protected]:~/wp
rsync -exclude=/.git/ -azvv -e ssh '.' [email protected]:~/wp
rsync -exclude=/.git/* -azvv -e ssh '.' [email protected]:~/wp
rsync -exclude /.git/ -azvv -e ssh '.' [email protected]:~/wp
rsync -exclude /.git/* -azvv -e ssh '.' [email protected]:~/wp
rsync -exclude="/.git/*" -azvv -e ssh '.' [email protected]:~/wp
rsync -exclude "/.git/*" -azvv -e ssh '.' [email protected]:~/wp
rsync -exclude={.git/,"ansible/*"} -azvv -e ssh '.' [email protected]:~/wp
rsync -exclude {.git/,"ansible/*"} -azvv -e ssh '.' [email protected]:~/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?

2 Answers 2

2

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

1
  • 2
    Same for --exclude
    – PiedPiper
    Commented Jan 23, 2019 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 '.' [email protected]:~/wp

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

rsync --relative --exclude-from='/path-relative/sync_exclude.txt' -azvv -e ssh '.' [email protected]:~/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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .