Skip to content

Instantly share code, notes, and snippets.

@turikhay
Last active December 14, 2023 14:22
Show Gist options
  • Save turikhay/197944fe544d7dd3ed753134ae009043 to your computer and use it in GitHub Desktop.
Save turikhay/197944fe544d7dd3ed753134ae009043 to your computer and use it in GitHub Desktop.
Reliable(-ish) rsync

Reliable(-ish) rsync

Sometimes I have unreliable connection, but rsync (nor rclone) don't support automatic resumption of a single file.

$ rsync -P file1 remote:
file1
     34,358,880  79%  301.00kB/s    0:00:30  client_loop: send disconnect: Broken pipe

rsync: [sender] write error: Broken pipe (32)
rsync error: unexplained error (code 255) at io.c(848) [sender=3.2.7]

I've created simple script that gets the job done. Feel free to copy it to your $PATH (~/.local/bin or /bin)

$ rsync -P file1 remote:
file1
     34,358,880  79%  301.00kB/s    0:00:30  client_loop: send disconnect: Broken pipe

rsync: [sender] write error: Broken pipe (32)
rsync error: unexplained error (code 255) at io.c(848) [sender=3.2.7]
rclone failed. retrying...
file
     43,459,766 100%    6.37MB/s    0:00:06 (xfr#1, to-chk=0/1)
OK
#!/bin/bash
until rsync --partial "$@"
do
>&2 echo "rsync failed. retrying in 5s"
sleep 5
done
echo "OK"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment