10

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?
  • To "have it automatic" the --password-file option would provide the password to the server prompt. The file should just contain the passphrase in plaintext and do not allow other users to have read access. – altmas5 Aug 16 '13 at 15:54
5

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.

| improve this answer | |
  • I looked at the man and i cant figure out what will allow me to copy new files only and not update. – user274 Jul 13 '10 at 20:21
1

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy