save only last component of src fs in dest

Change zfs receive command to use -e (was -d).

Allow greater control of dest placement. srcpool/a/really/long/path
should not force me to deal with destpool/backupdest/a/really/long/path.
This commit is contained in:
Kevin McCormick 2016-08-04 16:26:07 -07:00
parent 473e51d89c
commit f2b40a2ce8

View File

@ -120,14 +120,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 -Fud "$destfs" ZFS "$srchost" send -R "$cur" | ZFS "$desthost" receive -Fue "$destfs"
# 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 -Fud "$destfs" ZFS "$srchost" send -R -I "$last" "$cur" | ZFS "$desthost" receive -Fue "$destfs"
fi fi
### ###