From 579f0ff2dd5fc15cff95df59b79ed2273abe75bc Mon Sep 17 00:00:00 2001 From: Les De Ridder Date: Fri, 3 Mar 2017 23:16:06 +0100 Subject: [PATCH] Retry remote commands on failure --- backup.fish | 20 ++++++++++++++++++++ bootstrap.fish | 7 ++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/backup.fish b/backup.fish index 85c713f..91b2d70 100755 --- a/backup.fish +++ b/backup.fish @@ -40,6 +40,11 @@ sync echo "Sending to target..." for snapshot in $snapshots sudo btrfs send -p $snapshot $snapshot-new | receive-on-target + while [ $status != 0 ] + echo "Sending failed, retrying..." + sleep 5 + sudo btrfs send -p $snapshot $snapshot-new | receive-on-target + end end echo "Replacing old snapshots..." @@ -55,11 +60,26 @@ for pair in $pairs if not test -f $mount/.btrfish-keepone rename-target-subvolume $subvol $subvol.(date +%Y-%m-%d) + while [ $status != 0 ] + echo "Renaming failed, retrying..." + sleep 5 + rename-target-subvolume $subvol $subvol.(date +%Y-%m-%d) + end else delete-target-subvolume $subvol + while [ $status != 0 ] + echo "Deleting failed, retrying..." + sleep 5 + delete-target-subvolume $subvol + end end rename-target-subvolume $subvol-new $subvol + while [ $status != 0 ] + echo "Renaming failed, retrying..." + sleep 5 + rename-target-subvolume $subvol-new $subvol + end sudo rm $mount/.btrfish-lock end diff --git a/bootstrap.fish b/bootstrap.fish index 11029da..4ca6ae9 100755 --- a/bootstrap.fish +++ b/bootstrap.fish @@ -1,6 +1,6 @@ #!/usr/bin/fish -set scriptdir (dirname (status --current-filename)) +set scriptdir (dirname (status --current-filename)) source $scriptdir/config.fish source $scriptdir/utils.fish @@ -37,6 +37,11 @@ sync echo "Sending to target..." for snapshot in $snapshots sudo btrfs send $snapshot | receive-on-target + while [ $status != 0 ] + echo "Sending failed, retrying..." + sleep 5 + sudo btrfs send $snapshot | receive-on-target + end end echo "Done!"