RSYNC from remote to local excluding folders

10,336

The problem here is likely to be with the paths in the exclude filters in rsync.

The paths used in the rsync file list are relative to the SOURCE path.

That is if your directory structure is

 /home/path/to/copy
                | files_to_copy
                     | file1
                     \ file2
                \ files_to_exclude
                     | file3
                     \ file4

Then if you issue the command

rsync -avr -e ssh user@host:/home/path/to/copy \
                 /home/user/www --exclude='files_to_exclude/*'

You will get the following structure in the copy

 /home/user/www
             | files_to_copy
                  | file1
                  \ file2
             \ files_to_exclude

If you do not want to have the directory files_to_exclude in the copy you may use the following command:

rsync -avr -e ssh user@host:/home/path/to/copy \
                 /home/user/www --exclude='files_to_exclude'
Share:
10,336

Related videos on Youtube

Rob
Author by

Rob

Updated on September 18, 2022

Comments

  • Rob
    Rob over 1 year

    How can I download from a remote server to local excluding folders or files?

    I have used something like this but the exclude doesn't work...

    rsync -avr -P -e ssh --exclude=/path/to/exclude/* user@ipaddress:/home/path/to/copy /home/user/www
    

    Suggestions?

    • Rob
      Rob almost 12 years
      I can't do reverse operation (launch rsync from my remote server to copy files to my local server) because I can't remote open my local server.
    • Rob
      Rob almost 12 years
      yes, also used: rsync -avr -P -e ssh --exclude="/path/to/exclude/*" user@ipaddress:/home/path/to/copy /home/user/www