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 setting up rsyncrypto to create a backup of my user directory. I read that to exclude directories I need to exclude with find and pipe to rsyncrypto.

I am trying to exclude all .svn directories from getting encrypted and synced.

Here is the find command I'm using. I don't see any .svn directories in the output:


find ~/Documents -type d ( -name .svn ) -prune -o -print


But when I pipe the output to rsyncrypto I see lots of .svn directories getting encrypted.


find ~/Documents -type d ( -name .svn ) -prune -o -print | rsyncrypto -vc --trim=3 --filelist - /tmp/Documents/ Documents.keys backup.crt


Can someone help me rewrite the command to exclude from rsyncrypto any files/folders that have .svn in their path?

share|improve this question
    
I'm trying to exclude more than one directory too: find ~/Documents -type d ( -name .svn -o -name .DS_Store ) -prune -o -print –  Richard Aug 21 '10 at 20:02
    
Looks like the --filestype directive is causing the trouble because it recurses any directory. Revising this then, can someone help me change my find so that it gets all files excluding those with .svn anywhere in their path? –  Richard Aug 21 '10 at 20:25

1 Answer 1

up vote 1 down vote accepted

Your original find command prints all directories except for those under a .svn directory, in particular it prints ~/Documents. Experimentally, rsynccrypto recurses into all existing directories in a filelist, even though (like you, I think) I understand the documentation to say that it should only recurse into directories with a / appended.

So you need to print only files that are not directories. This means you must restrict -print with -type f (to back up only regular files) or ! -type d (to back up all non-directories, including symbolic links).

find ~/Documents -type d \( -name .svn -o -name .DS_Store \) -prune \
              -o \! -type d -print

Note that this won't back up the modification time and ownership of directories, or empty directories. This will include empty directories as well:

find ~/Documents -type d \( -name .svn -o -name .DS_Store \) -prune \
              -o \! -type d -print \
              -o -type d -empty -print
share|improve this answer
    
Thanks Giles, that works perfectly. I even added a condition to exclude a few files too. Teach a man to fish... –  Richard Aug 21 '10 at 23: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.