3

I'm running the following rsync command

rsync --times -v --recursive --compress --exclude "*.svn" --rsh=/usr/bin/ssh source/folder/ user@ip:httpdocs/

which excludes *.svn files when running. My question is how do I pass it a list of file types to exclude. There are a lot of non-essential hidden files in our development copy (IDE project files and osx specific files)

I need to pass in a list of 5 or 6 file extensions for rsync to ignore.

thanks

1 Answers1

6

Use the --exclude-from option, and specify a text file with all the patterns you want to avoid in it, like:

rsync --times -v --recursive --compress --exclude-from /tmp/filelist.txt --rsh=/usr/bin/ssh source/folder/ user@ip:httpdocs/
RainyRat
  • 3,730
  • 1
  • 24
  • 29
  • 6
    Or you can specify the --exclude option multiple times. – womble Nov 27 '09 at 09:19
  • Great thanks, do I just put the file types each on a new line in /tmp/filelist.txt ? –  Nov 27 '09 at 09:26
  • I like it when my command lines span both my monitors :) – RainyRat Nov 27 '09 at 09:27
  • 1
    ...and yes, each pattern on a new line. – RainyRat Nov 27 '09 at 09:28
  • You can say `--exclude={"/tmp","/lost+found:} etc. But NEVER use the backslash to shorten pieces of the list to fit your screen - it breaks it. Instead, use multiple excludes, like @wombie said. Or use the list in a file. RainyRat has a real point there. Not to mention having to scroll right and left if these long command lines get posted here. – SDsolar Aug 24 '17 at 02:01
  • Unfortunately, `rsync` with `--delete` does not remove files on the destination server that are in `--exclude` or `--exclude-from`. Any way to achieve that? – not2savvy Jan 28 '22 at 17:57