diff --git a/src/zfs-auto-snapshot.sh b/src/zfs-auto-snapshot.sh index 2573ec2..2d98f6c 100755 --- a/src/zfs-auto-snapshot.sh +++ b/src/zfs-auto-snapshot.sh @@ -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='' @@ -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 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. @@ -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 @@ -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 @@ -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