After reading through a bunch of troubleshooting threads, the following:
- Runs a shell script via cron
- SSH into a remote server using a SSH key for a password
- Executes Rysnc with the options to delete source files after download, and skip files with the extension .part
#!/bin/sh /usr/bin/rsync -havzPe 'ssh -i /home/alex/.ssh/id_rsa' --rsync path='/usr/bin/rsync' --remove-source-files --exclude='*.part' --stats firstname.lastname@example.org:/home/alex/target /home/alex | /usr/bin/mail -s 'Rsync Output' root
Crontab consisted of the following:
0 */2 * * * /home/alex/sync.sh >/dev/null 2>&1
This runs the shell script every 2 hours. This was created using a this crontab generator.
Generating a SSH key for passwordless SSH login and exporting it remotely is explained here.
Generate the keys on your host server:
ssh-keygen -t dsa
Export the keys to the target server:
ssh-copy-id -i ~/.ssh/id_dsa.pub ross@remotehost [or enter ip address instead of hostname, e.g."remotehost"]
Configure email server so mail command works.