Skip to content

Commit 49b2b5f

Browse files
committed
Implement --send-{ssh,mbuf}-opts for the snapshot replication.
1 parent b0126e0 commit 49b2b5f

File tree

2 files changed

+51
-23
lines changed

2 files changed

+51
-23
lines changed

src/zfs-auto-snapshot.8

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ Option(s) passed to 'zfs send'.
5858
\fB\-\-recv\-opts\fR=\fIOPTS\fR
5959
Option(s) passed to 'zfs receive'.
6060
.TP
61+
\fB\-\-send\-ssh\-opts\fR=\fIOPTS\fR
62+
Option(s) passed to 'ssh' in the replication command line.
63+
.sp
64+
See \fBssh\fR(1) for availible options.
65+
.TP
66+
\fB\-\-send\-mbuf\-opts\fR=\fIOPTS\fR
67+
Use \fBmbuffer\fR (with these options) between 'zfs send' and
68+
\'ssh <host> zfs receive <pool>'.
69+
.sp
70+
See \fBmbuffer\fR(1) for availible options.
71+
.TP
6172
\fB\-\-sep\fR=\fICHAR\fR
6273
Use CHAR to separate date stamps in snapshot names.
6374
.TP

src/zfs-auto-snapshot.sh

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ opt_send_host=''
3939
opt_recv_pool=''
4040
opt_send_opts=''
4141
opt_recv_opts=''
42+
opt_send_ssh_opts=''
43+
opt_send_mbuf_opts=''
4244
opt_sep='_'
4345
opt_setauto=''
4446
opt_syslog=''
@@ -63,27 +65,30 @@ SNAPS_DONE=''
6365
print_usage ()
6466
{
6567
echo "Usage: $0 [options] [-l label] <'//' | name [name...]>
66-
--default-exclude Exclude datasets if com.sun:auto-snapshot is unset.
67-
-d, --debug Print debugging messages.
68-
-e, --event=EVENT Set the com.sun:auto-snapshot-desc property to EVENT.
69-
--fast Use a faster zfs list invocation.
70-
-n, --dry-run Print actions without actually doing anything.
71-
-s, --skip-scrub Do not snapshot filesystems in scrubbing pools.
72-
-h, --help Print this usage message.
73-
-k, --keep=NUM Keep NUM recent snapshots and destroy older snapshots.
74-
-l, --label=LAB LAB is usually 'hourly', 'daily', or 'monthly'.
75-
-p, --prefix=PRE PRE is 'zfs-auto-snap' by default.
76-
-q, --quiet Suppress warnings and notices at the console.
77-
--send-full=F Send zfs full backup.
78-
--send-incr=F Send zfs incremental backup.
79-
--send-opts=F Option(s) passed to 'zfs send'.
80-
--recv-opts=F Option(s) passed to 'zfs receive'.
81-
--sep=CHAR Use CHAR to separate date stamps in snapshot names.
82-
-g, --syslog Write messages into the system log.
83-
-r, --recursive Snapshot named filesystem and all descendants.
84-
-v, --verbose Print info messages.
85-
--destroy-only Only destroy older snapshots, do not create new ones.
86-
name Filesystem and volume names, or '//' for all ZFS datasets.
68+
--default-exclude Exclude datasets if com.sun:auto-snapshot is unset.
69+
-d, --debug Print debugging messages.
70+
-e, --event=EVENT Set the com.sun:auto-snapshot-desc property to EVENT.
71+
--fast Use a faster zfs list invocation.
72+
-n, --dry-run Print actions without actually doing anything.
73+
-s, --skip-scrub Do not snapshot filesystems in scrubbing pools.
74+
-h, --help Print this usage message.
75+
-k, --keep=NUM Keep NUM recent snapshots and destroy older snapshots.
76+
-l, --label=LAB LAB is usually 'hourly', 'daily', or 'monthly'.
77+
-p, --prefix=PRE PRE is 'zfs-auto-snap' by default.
78+
-q, --quiet Suppress warnings and notices at the console.
79+
--send-full=F Send zfs full backup.
80+
--send-incr=F Send zfs incremental backup.
81+
--send-opts=F Option(s) passed to 'zfs send'.
82+
--recv-opts=F Option(s) passed to 'zfs receive'.
83+
--send-ssh-opts Option(s) passed to 'ssh'.
84+
--send-mbuf-opts Use mbuffer (with these options) between 'zfs send'
85+
and 'ssh <host> zfs receive'.
86+
--sep=CHAR Use CHAR to separate date stamps in snapshot names.
87+
-g, --syslog Write messages into the system log.
88+
-r, --recursive Snapshot named filesystem and all descendants.
89+
-v, --verbose Print info messages.
90+
--destroy-only Only destroy older snapshots, do not create new ones.
91+
name Filesystem and volume names, or '//' for all ZFS datasets.
8792
"
8893
}
8994

@@ -220,10 +225,14 @@ do_send () # snapname, oldglob
220225
local NAME="$1"
221226
local GLOB="$2"
222227
local RUNSEND=1
223-
local remote="ssh $opt_send_host zfs receive $opt_recv_opts $opt_recv_pool"
228+
local remote
224229
local ii
225230
local jj
226231

232+
[ -n "$opt_send_mbuf_opts" ] && remote="mbuffer $opt_send_mbuf_opts |"
233+
remote="$remote ssh $opt_send_ssh_opts $opt_send_host "
234+
remote="$remote zfs receive $opt_recv_opts $opt_recv_pool"
235+
227236
# STEP 1: Go throug all snapshots we've created
228237
for ii in $SNAPS_DONE
229238
do
@@ -309,7 +318,7 @@ GETOPT=$(getopt \
309318
--longoptions=debug,help,quiet,syslog,verbose \
310319
--longoptions=pre-snapshot:,post-snapshot:,destroy-only \
311320
--longoptions=send-full:,send-incr:,send-opts:,recv-opts: \
312-
--longoptions=pre-send:,post-send: \
321+
--longoptions=send-ssh-opts:,send-mbuf-opts:,pre-send:,post-send: \
313322
--options=dnshe:l:k:p:rs:qgv \
314323
-- "$@" ) \
315324
|| exit 128
@@ -418,6 +427,14 @@ do
418427
opt_recv_opts="$2"
419428
shift 2
420429
;;
430+
(--send-ssh-opts)
431+
opt_send_ssh_opts="$2"
432+
shift 2
433+
;;
434+
(--send-mbuf-opts)
435+
opt_send_mbuf_opts="$2"
436+
shift 2
437+
;;
421438
(--sep)
422439
case "$2" in
423440
([[:alnum:]_.:\ -])

0 commit comments

Comments
 (0)