0

I have the source directory : /media/Documents/source

and inside 'source' ,dir1,dir2 etc..

I am trying:

rsync -avzhe ssh  --exclude /dir1 --exclude /dir2  /media/Documents/source user@192.168.1.3:/media/Documents/

but it keeps transfering dir1 ,dir2 to destination.

I have tried various ways:

--exclude=/dir1 

 or --exclude dir1/ 

or --exclude 'dir1' etc.. but nothing works

0

The --exclude 'dir1/'should work. One thing to keep in mind is that the pattern that you use (in your case "dir1/" is a relative pattern to your source.

The geek-stuff blog has some good examples on how to use rsync with exclusions: http://www.thegeekstuff.com/2011/01/rsync-exclude-files-and-folders/

  • :But it doesn't work..I already checked that blog.. – George Jan 4 '14 at 18:53
  • It's important to use the trailing / in your case --exclude 'dir1/'. The files that you have excluded will still remain at your destination unless you remove these manually or specify --delete-excluded. – Dick Svensson Jan 4 '14 at 19:27
  • :OK!Now I need help!!!I used "rsync -avzhe ssh --progress --delete-excluded '/home/user/temp/test1/' /home/user/temp user@192.168.1.3:/home/user " to test it but it deleted all /home/user in 192.168.1.3 !Any way to reverse it??? – George Jan 4 '14 at 20:27
  • Your command should include --exclude 'dir1/' as well if you want to use the --delete-excluded. Your command replicates the files from your host to the remote host, but removes the folder that you did include in your exclusion filter. So for your test folder that's --exclude 'test1/' --delete-excluded temp user@192.168.1.3:/home/user/temp – Dick Svensson Jan 4 '14 at 21:30
  • :Ok ,that did it,thanks (I have to format my drive of course due to the previous deletion) – George Jan 5 '14 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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