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

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

2 Answers

up vote 6 down vote accepted

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.

share|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. –  acidzombie24 Jul 13 '10 at 20:21
add comment

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.

share|improve this answer
add comment

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.