Skip to content

Commit

Permalink
Implement do_destroy_remotes() to destroy the exact same snapshots
Browse files Browse the repository at this point in the history
on remote host(s) which is destroyed on localhost.
  • Loading branch information
FransUrbo committed Apr 3, 2015
1 parent 88725d9 commit 074b2e7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/zfs-auto-snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ WARNING_COUNT='0'
# Other global variables.
SNAPSHOTS_OLD=''
SNAPS_DONE=''
SNAPS_DESTROY=''


print_usage ()
Expand Down Expand Up @@ -288,6 +289,8 @@ $tmp"
if do_run "zfs destroy $FLAGS '$jj'"
then
DESTRUCTION_COUNT=$(( $DESTRUCTION_COUNT + 1 ))
[ -n "$opt_send" ] && SNAPS_DESTROY="$SNAPS_DESTROY
$jj"
else
WARNING_COUNT=$(( $WARNING_COUNT + 1 ))
fi
Expand Down Expand Up @@ -361,6 +364,24 @@ do_send () # snapname, oldglob
done
}


do_destroy_remotes ()
{
local FLAGS="$1"
local ii
local remote_ssh="ssh $opt_send_ssh_opts"

# Go through each option to --send-{incr,full}.
# rem=<remote_host>:<remote_pool>
for rem in $opt_send; do
for ii in $SNAPS_DESTROY
do
do_run "$remote_ssh ${rem%:*} zfs destroy $FLAGS '$ii'"
done
done
}


# main ()
# {

Expand Down Expand Up @@ -774,6 +795,7 @@ do_snapshots "$SNAPPROP" "" "$SNAPNAME" "$SNAPGLOB" "$TARGETS_REGULAR"
do_snapshots "$SNAPPROP" "-r" "$SNAPNAME" "$SNAPGLOB" "$TARGETS_RECURSIVE"

do_send "$SNAPNAME" "$SNAPGLOB"
do_destroy_remotes

print_log notice "@$SNAPNAME," \
"$SNAPSHOT_COUNT created," \
Expand Down

0 comments on commit 074b2e7

Please sign in to comment.