Skip to content

Commit 0f8ebf4

Browse files
wankdankerFransUrbo
authored andcommitted
Implement --send-only for the snapshot replication.
Used for skipping snapshotting and only do the replication part.
1 parent 586287e commit 0f8ebf4

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/zfs-auto-snapshot.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ opt_send_type=''
3838
opt_send_host=''
3939
opt_recv_pool=''
4040
opt_send_opts=''
41+
opt_send_only=''
4142
opt_recv_opts=''
4243
opt_send_ssh_opts=''
4344
opt_send_mbuf_opts=''
@@ -85,6 +86,7 @@ print_usage ()
8586
--send-ssh-opts Option(s) passed to 'ssh'.
8687
--send-mbuf-opts Use mbuffer (with these options) between 'zfs send'
8788
and 'ssh <host> zfs receive'.
89+
--send-only Only send the the most recent snapshot
8890
--sep=CHAR Use CHAR to separate date stamps in snapshot names.
8991
-g, --syslog Write messages into the system log.
9092
-r, --recursive Snapshot named filesystem and all descendants.
@@ -196,6 +198,21 @@ $ii@$NAME"
196198
fi
197199
fi
198200

201+
if [ -n "$opt_send_only" ]
202+
then
203+
for jj in $SNAPSHOTS_OLD
204+
do
205+
echo $SNAPS_DONE | grep -qv $ii
206+
if [ -z "${jj#$ii@$GLOB}" -a $? -eq 0 ]
207+
then
208+
SNAPS_DONE="$SNAPS_DONE
209+
$jj"
210+
echo adding $jj
211+
fi
212+
done
213+
continue;
214+
fi
215+
199216
# Retain at most $opt_keep number of old snapshots of this filesystem,
200217
# including the one that was just recently created.
201218
test -z "$opt_keep" && continue
@@ -338,7 +355,7 @@ GETOPT=$(getopt \
338355
--longoptions=pre-snapshot:,post-snapshot:,destroy-only \
339356
--longoptions=send-full:,send-incr:,send-opts:,recv-opts: \
340357
--longoptions=send-ssh-opts:,send-mbuf-opts:,pre-send:,post-send: \
341-
--longoptions=send-fallback \
358+
--longoptions=send-fallback,send-only \
342359
--options=dnshe:l:k:p:rs:qgv \
343360
-- "$@" ) \
344361
|| exit 128
@@ -443,6 +460,11 @@ do
443460
opt_send_fallback=1
444461
shift 1
445462
;;
463+
(--send-only)
464+
opt_send_only=1
465+
opt_do_snapshots=''
466+
shift 1
467+
;;
446468
(--send-opts)
447469
opt_send_opts="$2"
448470
shift 2

0 commit comments

Comments
 (0)