Sync directories across servers

nohup rsync --partial --progress -avvvz -e "ssh -i /root/.ssh/id_rsa" ./backups [email protected]:~/ &

Here, the directory ./backups from current server is being transferred over to the remote server at 192.157.59.133. The ssh authentication normally requires a password. We have already setup a key for the server. The public key corresponding to id_rsa has been appended to .ssh/authorized_keys on remote server, so it works without asking for a password.

The command immediately returns to the shell.

If you wish to see the progress, exec:

tail -f nohup.out

In this way you can see the progress but still avoid the connection terminating and stopping the transfer. Even if disconnected this kind of command allows resume at the failed position.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.