Retry remote commands on failure

This commit is contained in:
Les De Ridder 2017-03-03 23:16:06 +01:00
parent 4e3b68e13c
commit 579f0ff2dd
No known key found for this signature in database
GPG Key ID: 5EC132DFA85DB372
2 changed files with 26 additions and 1 deletions

View File

@ -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

View File

@ -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!"