Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
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

2 Answers 2

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

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/
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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