Skip to content

Commit dfdfe07

Browse files
committed
Implement --send-{ssh,mbuf}-opts for the snapshot replication.
1 parent 9183d3f commit dfdfe07

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=''
@@ -62,27 +64,30 @@ SNAPSHOTS_OLD=''
6264
print_usage ()
6365
{
6466
echo "Usage: $0 [options] [-l label] <'//' | name [name...]>
65-
--default-exclude Exclude datasets if com.sun:auto-snapshot is unset.
66-
-d, --debug Print debugging messages.
67-
-e, --event=EVENT Set the com.sun:auto-snapshot-desc property to EVENT.
68-
--fast Use a faster zfs list invocation.
69-
-n, --dry-run Print actions without actually doing anything.
70-
-s, --skip-scrub Do not snapshot filesystems in scrubbing pools.
71-
-h, --help Print this usage message.
72-
-k, --keep=NUM Keep NUM recent snapshots and destroy older snapshots.
73-
-l, --label=LAB LAB is usually 'hourly', 'daily', or 'monthly'.
74-
-p, --prefix=PRE PRE is 'zfs-auto-snap' by default.
75-
-q, --quiet Suppress warnings and notices at the console.
76-
--send-full=F Send zfs full backup. Unimplemented.
77-
--send-incr=F Send zfs incremental backup. Unimplemented.
78-
--send-opts=F Option(s) passed to 'zfs send'.
79-
--recv-opts=F Option(s) passed to 'zfs receive'.
80-
--sep=CHAR Use CHAR to separate date stamps in snapshot names.
81-
-g, --syslog Write messages into the system log.
82-
-r, --recursive Snapshot named filesystem and all descendants.
83-
-v, --verbose Print info messages.
84-
--destroy-only Only destroy older snapshots, do not create new ones.
85-
name Filesystem and volume names, or '//' for all ZFS datasets.
67+
--default-exclude Exclude datasets if com.sun:auto-snapshot is unset.
68+
-d, --debug Print debugging messages.
69+
-e, --event=EVENT Set the com.sun:auto-snapshot-desc property to EVENT.
70+
--fast Use a faster zfs list invocation.
71+
-n, --dry-run Print actions without actually doing anything.
72+
-s, --skip-scrub Do not snapshot filesystems in scrubbing pools.
73+
-h, --help Print this usage message.
74+
-k, --keep=NUM Keep NUM recent snapshots and destroy older snapshots.
75+
-l, --label=LAB LAB is usually 'hourly', 'daily', or 'monthly'.
76+
-p, --prefix=PRE PRE is 'zfs-auto-snap' by default.
77+
-q, --quiet Suppress warnings and notices at the console.
78+
--send-full=F Send zfs full backup. Unimplemented.
79+
--send-incr=F Send zfs incremental backup. Unimplemented.
80+
--send-opts=F Option(s) passed to 'zfs send'.
81+
--recv-opts=F Option(s) passed to 'zfs receive'.
82+
--send-ssh-opts Option(s) passed to 'ssh'.
83+
--send-mbuf-opts Use mbuffer (with these options) between 'zfs send'
84+
and 'ssh <host> zfs receive'.
85+
--sep=CHAR Use CHAR to separate date stamps in snapshot names.
86+
-g, --syslog Write messages into the system log.
87+
-r, --recursive Snapshot named filesystem and all descendants.
88+
-v, --verbose Print info messages.
89+
--destroy-only Only destroy older snapshots, do not create new ones.
90+
name Filesystem and volume names, or '//' for all ZFS datasets.
8691
"
8792
}
8893

@@ -221,9 +226,13 @@ do_send () # snapname, oldglob
221226
local NAME="$1"
222227
local GLOB="$2"
223228
local RUNSEND=1
224-
local remote="ssh $opt_send_host zfs receive $opt_recv_opts $opt_recv_pool"
229+
local remote
225230
local ii
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
@@ -310,7 +319,7 @@ GETOPT=$(getopt \
310319
--longoptions=debug,help,quiet,syslog,verbose \
311320
--longoptions=pre-snapshot:,post-snapshot:,destroy-only \
312321
--longoptions=send-full:,send-incr:,send-opts:,recv-opts: \
313-
--longoptions=pre-send:,post-send: \
322+
--longoptions=send-ssh-opts:,send-mbuf-opts:,pre-send:,post-send: \
314323
--options=dnshe:l:k:p:rs:qgv \
315324
-- "$@" ) \
316325
|| exit 128
@@ -419,6 +428,14 @@ do
419428
opt_recv_opts="$2"
420429
shift 2
421430
;;
431+
(--send-ssh-opts)
432+
opt_send_ssh_opts="$2"
433+
shift 2
434+
;;
435+
(--send-mbuf-opts)
436+
opt_send_mbuf_opts="$2"
437+
shift 2
438+
;;
422439
(--sep)
423440
case "$2" in
424441
([[:alnum:]_.:\ -])

0 commit comments

Comments
 (0)