2

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?

  • 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 Jun 6 '12 at 15:07
  • 2
    Did you protect globstar '*' from expansion with single quotes? – Dmitri Chubarov Jun 6 '12 at 15:28
  • yes, also used: rsync -avr -P -e ssh --exclude="/path/to/exclude/*" user@ipaddress:/home/path/to/copy /home/user/www – Rob Jun 7 '12 at 9:35
4

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'
| improve this answer | |
0

We use something similar to this

filename=`date +%F`_backup
rsync --verbose --log-file=/backup_logs/"$filename" --progress --stats --compress --rsh=/usr/bin/ssh --recursive --times --perms --links --delete --exclude '*.zip' user@remoteMachine:/data/documents/ /local/data/documents/
| improve this answer | |

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.