Subversion Repositories zfs_utils

Rev

Rev 4 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7 rodolico 1
replicate is a script which is designed to manage replicating two sets of
2 rodolico 2
ZFS snapshots. There are tons of them out there, and this is pretty
3
simplistic, especially as compared to some of the more throurough ones like
7 rodolico 4
repl, etc... If you need more than just replication, look at those.
2 rodolico 5
 
7 rodolico 6
I wrote replication to handle a specific problem. I wanted separate scripts
7
for replication, pruning and snapshot creation so I could have greater
8
control over what happened on each machine. In one case, we had 'production'
9
backing up to 'backup' which was then backed up to 'airgap', each on a
10
different schedule, and with different retention policies.
2 rodolico 11
 
7 rodolico 12
replicate was designed to be a simple command to call that would do one
13
single dataset replication (recursive, if desired). As such, it can be
14
called from a crontab simply as
2 rodolico 15
 
7 rodolico 16
replicate source target # positional invocation
17
or
18
replicate -s source -t target # using flags
19
 
20
For more complex operations, the included sample script, sync, will 
21
read a configuration file and process each dataset in turn. See sync.md for
22
more information on that. It is mainly a "howto" to help you build your
23
own script.
24
 
25
replicate has two modes, a simplistic positional mode similar to cp
26
replicate source target
27
 
28
However, there are many flags that can be invoked to do additional things.
29
When flags and positional are combined, the flags will override the
30
positions, so
31
replicate -s source1 source2
32
will replicate from source1, not from source2
33
 
34
Flags
35
flags gan be passed as single characters (except bwlimit) and combined, thus
36
replicate -nrv
37
is the same as
38
replicate -n -r -v
39
 
40
--source or -s  
41
define the source, the thing to be replicated from
42
 
43
--target or -t
44
The target system, which will be syncronized from --source, only as limited
45
by --filter
46
 
47
--filter or -f
48
Filter (regex) to limit source snapshots to process. This is a Perl regular
49
expression, with all of the power that gives you. The default is "something
50
that looks like a datetimestamp, ie
51
(\d{4}.\d{2}.\d{2}.\d{2}.\d{2})
52
which is 5 fields containing 4, 2, 2, 2, 2 digits each, with any character
53
inbetween. This will match 2025/04/26_18:25. Unfortunately, it will also
54
match 2025104526218625. However, it will work for most applications.
55
 
56
--dryrun or -n
57
Only displays command(s) to be run. When in this mode, if pv is installed,
58
it will place a pv command (pv -petrs ###) between the source and target to
59
display an estimated completion if you run the command from the CLI
60
 
61
--recurse or -r
62
Process dataset and all child datasets. I thought about making this the
63
default, but decided not to. I assume this flag would be used more
64
consistently than any of the others. Without it, will will only replicate
65
the single dataset, ignoring all children
66
 
67
--verbose or -v
68
Increase verbosity of output. Without this flag, no output is produced
69
(except for --dryrun). Adding this flag once will return a brief, easily
70
parseable output saying how many bytes were in the source datasets snapshots
71
(and any children), so an approximation of how much data must be
72
transferred. A second field shows the number of seconds the replication
73
took.
74
 
75
-vv: using verbose twice will return all output from the local part of the 
76
replicate command (adding a -v to either send or receive)
77
 
78
--bwlimit
79
Limit the speed of the connect to # bytes/s. You can use the modifiers K, M,
80
G, T after the number. The multipliers are 1024 (si).
81
 
82
This is only available if the unix command pv is installed and accessible to
83
the script. It will be ignored otherwise. The --si flag is passed to pv
84
also. Note that this is bytes per second, not bits, so if you want to use
85
half of a 10Mb/s line, you'll have to divide by 8 (integers only, so either
86
1M, which would be 8Mb/s, or 2, resulting in 16Mb/s.
87
 
88
 
89