mirror of
https://github.com/bashclub/bashclub-zfs-push-pull.git
synced 2024-11-07 21:01:58 +01:00
exit on failure of critical zfs commands
Execution should not continue upon failure of certain zfs commands. In particular, cleanup/rotation of the oldest snapshots will no longer occur upon a failure to send/receive.
This commit is contained in:
parent
12f7666a2f
commit
0850e82df3
@ -118,7 +118,7 @@ fi
|
|||||||
### create new snapshot on src
|
### create new snapshot on src
|
||||||
###
|
###
|
||||||
cur="$srcfs@${tag}_$date"
|
cur="$srcfs@${tag}_$date"
|
||||||
ZFS "$srchost" snapshot -r "$cur"
|
ZFS "$srchost" snapshot -r "$cur" || die $? "zfs snapshot failed"
|
||||||
|
|
||||||
###
|
###
|
||||||
### find newest snapshot matching the tag on dest
|
### find newest snapshot matching the tag on dest
|
||||||
@ -132,14 +132,14 @@ last="$(ZFS "$desthost" list -d 1 -t snapshot -H -S creation -o name $destfs/$sr
|
|||||||
# 1st time: send full snapshot
|
# 1st time: send full snapshot
|
||||||
if [[ -z $last ]] ; then
|
if [[ -z $last ]] ; then
|
||||||
log "sending full recursive snapshot from $src to $dest"
|
log "sending full recursive snapshot from $src to $dest"
|
||||||
ZFS "$srchost" send -R "$cur" | ZFS "$desthost" receive -Fue "$destfs"
|
ZFS "$srchost" send -R "$cur" | ZFS "$desthost" receive -Fue "$destfs" || die $? "zfs full send failed"
|
||||||
# special case: tagged snapshots exist on dest, but src has rotated through all
|
# special case: tagged snapshots exist on dest, but src has rotated through all
|
||||||
elif ! ZFS "$srchost" list $srcfs@$last &>/dev/null ; then
|
elif ! ZFS "$srchost" list $srcfs@$last &>/dev/null ; then
|
||||||
die 1 "no incremental path from from $src to $dest"
|
die 1 "no incremental path from from $src to $dest"
|
||||||
# normal case: send incremental
|
# normal case: send incremental
|
||||||
else
|
else
|
||||||
log "sending incremental snapshot from $src to $dest (${last#${tag}_}..${cur#*@${tag}_})"
|
log "sending incremental snapshot from $src to $dest (${last#${tag}_}..${cur#*@${tag}_})"
|
||||||
ZFS "$srchost" send -R -I "$last" "$cur" | ZFS "$desthost" receive -Fue "$destfs"
|
ZFS "$srchost" send -R -I "$last" "$cur" | ZFS "$desthost" receive -Fue "$destfs" || die $? "zfs incremental send failed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###
|
###
|
||||||
|
Loading…
Reference in New Issue
Block a user