MacsandaPi
Posts: 103
Joined: Tue Dec 30, 2014 7:44 pm

rsync error when trying to exclude files

Sun May 22, 2016 8:44 pm

I want to use rsync to backup my pi's home directory over a network, but get an error message when I run the following:

Code: Select all

rsync -av --exclude".*/" pi@192.168.1.111:/home/pi/ ~/RPi-backup
(BTW, the above line is copied from https://www.raspberrypi.org/learning/no ... l/backup/

The error message is:

Code: Select all

rsync: --exclude.*/: unknown option
rsync error: syntax or usage error (code 1) at /SourceCache/rsync/rsync-40/rsync/main.c(1333) [client=2.6.9]
How can I correct this to get rsync to backup my home directory excluding the invisible files?

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: rsync error when trying to exclude files

Sun May 22, 2016 9:01 pm

I suggest a space between exclude and "

(I agree you appear to have copied the command correctly: maybe there is a formatting error on the documentation page.)

[Edit: or try --exclude=" ]

MacsandaPi
Posts: 103
Joined: Tue Dec 30, 2014 7:44 pm

Re: rsync error when trying to exclude files

Sun May 22, 2016 9:30 pm

Many thanks for the suggestions. I tried them and both allow the command to run without error. However, when I go to the new directory (RPi-backup) and use ls -a, it shows that the "dot files," i.e., the "invisible" ones have been copied and included in the new directory, even though the rsync command was made to exclude them.

So, progress has been made in getting the rsync command to run, but I would like to know how to get the exclusion feature to work. Thank you again for your help.

User avatar
Paeryn
Posts: 2966
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: rsync error when trying to exclude files

Sun May 22, 2016 11:19 pm

You have a trailing / in the exclude pattern so that will exclude only directories starting with a dot, files will still be included.
She who travels light — forgot something.

MacsandaPi
Posts: 103
Joined: Tue Dec 30, 2014 7:44 pm

Re: rsync error when trying to exclude files

Mon May 23, 2016 6:16 pm

Thank you for this information. The exclude command now works as I wanted it to. It's very unlikely that I would have figured this out on my own, even after looking at man rsync. Your help is appreciated!

User avatar
Paeryn
Posts: 2966
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: rsync error when trying to exclude files

Mon May 23, 2016 7:33 pm

MacsandaPi wrote:Thank you for this information. The exclude command now works as I wanted it to. It's very unlikely that I would have figured this out on my own, even after looking at man rsync. Your help is appreciated!
You're welcome.

I've just checked the man page, you probably would've found it eventually, it's listed as the second point in the include/exclude pattern rules section (at about line 3152)
if the pattern ends with a / then it will only match a directory, not a regular file, symlink, or device.
She who travels light — forgot something.

Return to “Beginners”