Rsync is great for transfering large files over SSH, especially on unstable connections. It can resume copying but lacks an automatic retry option.

I was using this command to transfer a big image snapshot from one server to an other

rsync --progress --partial --inplace /mnt/playground_2021-03-24.img.gpg picloud@10.25.40.6:/mnt/backups/project-insanity/

If this command fails, for example because the remote host is unreachable for a short time, you can resume the transfer by running the same command again. We could wrap this into a small for-loop in Bash which would execute rsync again in case of errors. Before scripting this for myself I found something similar on Github from the user felipou and packaged it for ArchLinux user repository. It is a small retry script which you can prepend to the rsync command

retry rsync --progress --partial --inplace /mnt/playground_2021-03-24.img.gpg picloud@10.25.40.6:/mnt/backups/project-insanity/

On the screenshot you can see rsync gets rerun several times as long as the transfer fails

The retry script stops after 10 attempts (which is adjustable) or after an succesful transfer.

💬 Are you interested in our work or have some questions? Join us in our public Signal chat pi crew 👋
🪙 If you like our work or want to supprot us, you can donate MobileCoins to our address.