Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am trying to set up rsync to syncronize my main web server to the remote server by adding newly generated file to the later.

Here is the command that I use:

rsync -avh --update -e "ssh -i /path/to/thishost-rsync-key" remoteuser@remotehost:/foo/bar /foo/bar

But it seems that the web server actually transfers all files despite the '--update' flag. I have tried different flag combinations (e.g omitting '-a' and using'-uv' instead) but none helped. So wondering how can I modify the rsync command to send out only newly added files. Thanks

share|improve this question

3 Answers 3

From man rsync:

--ignore-existing       skip updating files that exist on receiver

--update does something slightly different, which is probably why you are getting unexpected results. Again, from man rsync:

This forces rsync to skip any files which exist on the destination and have a modified time that is newer than the source file. (If an existing destination file has a modification time equal to the source file's, it will be updated if the sizes are different.)

share|improve this answer
    
Well actually I tried the command with '--ignore-existing' instead of '--update'. It finished fast but does not put the new files into remote host. Any ideas? Thanks –  supermario Mar 12 '13 at 2:34
1  
@supermario Not sure what the issue it, it works for me. –  Chris Down Mar 14 '13 at 4:02
1  
Man pages suck (that's right I went there), case in point, does --ignore-existing mean don't transfer files which exist on receiver, or don't transfer files if some file/folder with the same name exists on the receiver? –  puk Nov 20 '13 at 9:05

In my case I had similar issues, having all files transferred instead of only the modified/new ones. I solved this by using parameters -t (instead of -a), and -P (equivalent to --partial --progress):

rsync -h -v -r -P -t source target

This transfers only new files, and files already existing but modified: -a does too much, like user and group ID sync, which in my case can not work as I have different users and group on my target system.

The parameters in detail:

  • -h: human readable numbers
  • -v: verbose
  • -r: recurse into directories
  • -P: --partial (keep partially transferred files) +
            --progress (show progress during transfer)
  • -t: preserve modification times
share|improve this answer

From my experience with rsync, a 1TB partition copying is too large to be efficient. It takes rsync forever to process it. Instead, do it by subdirectories. That is, run rsync for each main subdirectory. It goes a lot faster if it doesn't have to juggle tens of thousands of files.

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.