Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rsync over SSH - timeout in ssh or rsync?

Tags:

ssh

timeout

rsync

I'm dealing with a crappy ISP that resets my WAN connection at random points while my script is running. I want the transfer to survive this reset and go on. I manually launch this script vs using cron / launchd currently.

I have a fairly basic script as shown below:

rsync -rltv --progress --partial -e "ssh -i <key> -o ConnectTimeout=300" <remotedir> <localdir>

Am I better off putting the timeout in the rsync section instead?

For example:

rsync -rltv --progress--partial --timeout=300 -e "ssh -i <key>" <remotedir> <localdir>

Thanks!

like image 947
user1753780 Avatar asked Oct 17 '12 16:10

user1753780


People also ask

Does rsync run over SSH?

Rsync stands for "Remote Sync." The rsync command lets you transfer and synchronize data between different machines and directories. Using the Secure Shell (SSH) protocol, you can copy your files securely to another location. The rsync tool has many benefits when compared to other methods for copying files.

How do I keep rsync alive?

The solution to keep rsync running in background Nohup allows to run a process/command or shell script to continue working in the background even if you close the terminal session. In our example, we also added '&' at the end, that helps to send the process to background.


1 Answers

ConnectTimeout only applies when SSH is trying to establish the connection with the server, it doesn't have anything to do with timeouts during the data transfer. So you need to use the --timeout option to do what you want.

like image 90
Barmar Avatar answered Sep 19 '22 14:09

Barmar