rsync copy new files only, no updates?

I would like to use rsync to copy files from a remote server. I would like to

  • only copy files from server, not push any back out.
  • copy files that don't exist. If the remote file is newer I do not want to copy it
  • have it automatic. This prompts me for my password everytime and i would like it to be ran by cron. So how do I run it in a bash script executed by cron?

Solution 1:

Points 1 and 2: How to specify what to copy is best answered by reading the rsync manpage. In your case, look especially at --ignore-existing flag.

Point 3: This tutorial should get you going using passwordless ssh with rsync. Summary: set up passwordless ssh and use '-e ssh' to tell rsync to use ssh instead of rsh to connect to the remote host.

Solution 2:

For the second part, since pjz answered the rest, I believe you can use the --ignore-existing switch to only get new files.

From http://www.samba.org/ftp/rsync/rsync.html:

This tells rsync to skip updating files that already exist on the destination (this does not ignore existing directories, or nothing would get done). See also --existing. This option is a transfer rule, not an exclude, so it doesn't affect the data that goes into the file-lists, and thus it doesn't affect deletions. It just limits the files that the receiver requests to be transferred.

This option can be useful for those doing backups using the --link-dest option when they need to continue a backup run that got interrupted. Since a --link-dest run is copied into a new directory hierarchy (when it is used properly), using --ignore existing will ensure that the already-handled files don't get tweaked (which avoids a change in permissions on the hard-linked files). This does mean that this option is only looking at the existing files in the destination hierarchy itself.