Retry remote commands on failure
This commit is contained in:
parent
4e3b68e13c
commit
579f0ff2dd
20
backup.fish
20
backup.fish
|
@ -40,6 +40,11 @@ sync
|
||||||
echo "Sending to target..."
|
echo "Sending to target..."
|
||||||
for snapshot in $snapshots
|
for snapshot in $snapshots
|
||||||
sudo btrfs send -p $snapshot $snapshot-new | receive-on-target
|
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
|
end
|
||||||
|
|
||||||
echo "Replacing old snapshots..."
|
echo "Replacing old snapshots..."
|
||||||
|
@ -55,11 +60,26 @@ for pair in $pairs
|
||||||
|
|
||||||
if not test -f $mount/.btrfish-keepone
|
if not test -f $mount/.btrfish-keepone
|
||||||
rename-target-subvolume $subvol $subvol.(date +%Y-%m-%d)
|
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
|
else
|
||||||
delete-target-subvolume $subvol
|
delete-target-subvolume $subvol
|
||||||
|
while [ $status != 0 ]
|
||||||
|
echo "Deleting failed, retrying..."
|
||||||
|
sleep 5
|
||||||
|
delete-target-subvolume $subvol
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
rename-target-subvolume $subvol-new $subvol
|
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
|
sudo rm $mount/.btrfish-lock
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/fish
|
#!/usr/bin/fish
|
||||||
|
|
||||||
set scriptdir (dirname (status --current-filename))
|
set scriptdir (dirname (status --current-filename))
|
||||||
|
|
||||||
source $scriptdir/config.fish
|
source $scriptdir/config.fish
|
||||||
source $scriptdir/utils.fish
|
source $scriptdir/utils.fish
|
||||||
|
@ -37,6 +37,11 @@ sync
|
||||||
echo "Sending to target..."
|
echo "Sending to target..."
|
||||||
for snapshot in $snapshots
|
for snapshot in $snapshots
|
||||||
sudo btrfs send $snapshot | receive-on-target
|
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
|
end
|
||||||
|
|
||||||
echo "Done!"
|
echo "Done!"
|
||||||
|
|
Loading…
Reference in New Issue