9

I try to run a rsync on a shared server that I have no control over the ssh-config file to prevent the broken pipe error because the connection drop.

Here's a snippet of the code I use to backup

rsync -avz --blocking-io --delete-after --exclude 'mail*' /home user@remote:./backup/monthly/

Using this works fine for around 10min. , the the broken pipe error appears to tell me I've lost connection... probably because the rsync run in an idle state over SSH so SSH thinks I don't do anything while the rsync is running.

I've tried with and without --blocking-io but the connection still drop. Are they any trick to keep the SSH session alive until the rsync is complete without having access to the ssh-config file?

2 Answers 2

4

This works providing your running OpenSSH.

Edit your ~/.ssh/config file and add the following to activate the keep-alive system for just your user for all host connected to.

If you want to do this just for one host, switch the * with a host name of your choosing.

Host *
    ServerAliveInterval 300
    ServerAliveCountMax 2
3

You should use the parameter 'ServerAliveInterval' as below:

rsync -avzhe 'ssh -o ServerAliveInterval=60' local/dir/files your_user@remote:/destination/ 
1
  • Use: rsync -e "ssh -o ServerAliveInterval=60" instead of: rsync 'ssh -o ServerAliveInterval=60' Commented May 26, 2021 at 5:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .