Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to set up rsync for OS X 10.8.4 using an exclude file. However, it does not recognize the paths I want to exclude.

I want to copy the user ABC's home directory to a folder called Backup_Mac on a mounted external drive.

rsync -av --progress --exclude-from='/Users/ABC/excludelist.txt' /Users/ABC /Volumes/Backup_Mac

excludelist.txt contains

- /Users/ABC/Dropbox/

It is not excluding the Dropbox folder.

Now if I change the exclude file to

- Dropbox/

it is excluding ABC/Dropbox but also all other folders named Dropbox elsewhere in the file tree. This is not what I want – I want to exclude only the folder ABC/Dropbox but include any other folders called Dropbox, e.g. ABC/Application Support/Dropbox.

Any hint on how to achieve that? How do I have to specify the exclude path, relative to the folder backed up, or relative to root?

share|improve this question
1  
Does your list literally contain a hyphen and a space before the path? –  slhck Jul 28 '13 at 15:03
    
It does. I tried different variations (removing hyphen and/or space), none of them work. –  Alex Jul 28 '13 at 15:21

1 Answer 1

up vote 1 down vote accepted

Simply put, rsync uses relative paths to determine what to exclude. From the rsync manpage:

If the pattern starts with a / then it is anchored to a particular spot in the hierarchy of files, otherwise it is matched against the end of the pathname. This is similar to a leading ^ in regular expressions. Thus "/foo" would match a file named "foo" at either the "root of the transfer" (for a global rule) (…)

The simplest way to work around this is to use --relative / -R, which lets you exclude Dropbox like so:

rsync -avR --exclude='/Users/alex/Dropbox' /Users/alex /Volumes/Backup_Mac

The name relative refers to how rsync sends the paths and therefore doesn't have anything to do with specifying absolute exclude patterns.

Note that this creates the full directory tree /Volumes/Backup_Mac/Users/alex/, but that's not a terribly bad thing in your case.

share|improve this answer
    
That is the solution, indeed. Many thanks my friend. It also works using the 'exclude file', awesome! –  Alex Jul 28 '13 at 19:11
    
You're welcome, Alex! Since you're new to Super User, it'd be appreciated if you could accept an answer using the green checkmark next to it, if it worked for you. That'll help future visitors see which answers were useful. –  slhck Jul 28 '13 at 19:14
    
I was looking for how to mark the question as answered as we speak :) Thanks again –  Alex Jul 28 '13 at 19:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.