Skip to content

Commit

Permalink
Implement --send-only for the snapshot replication.
Browse files Browse the repository at this point in the history
Used for skipping snapshotting and only do the replication part.
  • Loading branch information
wankdanker authored and FransUrbo committed Apr 3, 2015
1 parent 586287e commit 0f8ebf4
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/zfs-auto-snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ opt_send_type=''
opt_send_host=''
opt_recv_pool=''
opt_send_opts=''
opt_send_only=''
opt_recv_opts=''
opt_send_ssh_opts=''
opt_send_mbuf_opts=''
Expand Down Expand Up @@ -85,6 +86,7 @@ print_usage ()
--send-ssh-opts Option(s) passed to 'ssh'.
--send-mbuf-opts Use mbuffer (with these options) between 'zfs send'
and 'ssh <host> zfs receive'.
--send-only Only send the the most recent snapshot
--sep=CHAR Use CHAR to separate date stamps in snapshot names.
-g, --syslog Write messages into the system log.
-r, --recursive Snapshot named filesystem and all descendants.
Expand Down Expand Up @@ -196,6 +198,21 @@ $ii@$NAME"
fi
fi

if [ -n "$opt_send_only" ]
then
for jj in $SNAPSHOTS_OLD
do
echo $SNAPS_DONE | grep -qv $ii
if [ -z "${jj#$ii@$GLOB}" -a $? -eq 0 ]
then
SNAPS_DONE="$SNAPS_DONE
$jj"
echo adding $jj
fi
done
continue;
fi

# Retain at most $opt_keep number of old snapshots of this filesystem,
# including the one that was just recently created.
test -z "$opt_keep" && continue
Expand Down Expand Up @@ -338,7 +355,7 @@ GETOPT=$(getopt \
--longoptions=pre-snapshot:,post-snapshot:,destroy-only \
--longoptions=send-full:,send-incr:,send-opts:,recv-opts: \
--longoptions=send-ssh-opts:,send-mbuf-opts:,pre-send:,post-send: \
--longoptions=send-fallback \
--longoptions=send-fallback,send-only \
--options=dnshe:l:k:p:rs:qgv \
-- "$@" ) \
|| exit 128
Expand Down Expand Up @@ -443,6 +460,11 @@ do
opt_send_fallback=1
shift 1
;;
(--send-only)
opt_send_only=1
opt_do_snapshots=''
shift 1
;;
(--send-opts)
opt_send_opts="$2"
shift 2
Expand Down

0 comments on commit 0f8ebf4

Please sign in to comment.