5

I am trying to backup files from cluster to my local computer. On the process, I am trying to avoid some unnecessary sub-directories from cluster being copied.

So I use rsync -av [email protected]:/home/dir . --exclude [email protected]:/home/dir/subdir, where subdir is the folder I am trying to avoid. However, the above option copies all files and folders including subdir. How to exclude subdir?

SKPS
  • 183
  • 2
  • 15

1 Answers1

5

The problem is that the path that you hand to --exclude should be relative to the original source path of the rsync command. This also means that you can do away with the / at the beginning of /subdir

Also there's no need to specify the user and host in the --exclude part.

So the correct command would be:

rsync -av [email protected]:/home/dir . --exclude subdir

Note that rsync --exclude can also do pattern matching, and the --exclude-from option is a great way to use a file listing multiple exclude patterns if you have more complicated exclusions.

Arronical
  • 19,893