@@ -8,12 +8,22 @@ snapshots continue to be taken even if the backup fails. It does not
8
8
necessarily require that package -- anything that regularly generates
9
9
snapshots that follow a given pattern will suffice.
10
10
11
+ Command-line options:
12
+ -n debug/dry-run mode
13
+ -v verbose mode
14
+ -f file specify a configuration file
15
+ -r N use the Nth most recent local snapshot rather than the newest
16
+ -h, -? display help message
17
+
11
18
12
19
Basic installation: After following the prerequisites, run manually to verify
13
20
operation, and then add a line like the following to zfssnap's crontab:
14
- 30 * * * * /path/to/zfs-backup.sh
21
+ 30 * * * * /path/to/zfs-backup.sh [ options ]
15
22
(This for an hourly sync -- adjust accordingly if you only want to back up
16
- daily, etc.)
23
+ daily, etc. zfs-backup now supports commandline options and configuration
24
+ files, so you can schedule different cron jobs with different config files,
25
+ e.g. to back up to two different targets. If you schedule multiple cron
26
+ jobs, you should use different lockfiles in each configuration.)
17
27
18
28
This aims to be much more robust than the backup functionality of
19
29
zfs-auto-snapshot, namely:
@@ -27,21 +37,23 @@ zfs-auto-snapshot, namely:
27
37
28
38
PREREQUISITES:
29
39
1. zfs-auto-snapshot or equivalent package installed locally and regular
30
- snapshots enabled (hourly, daily, etc.)
31
- 2. home directory set for zfssnap role
40
+ snapshots enabled (hourly, daily, etc.)
41
+ 2. home directory set for zfssnap role (the user taking snapshots and doing
42
+ the sending)
32
43
3. ssh keys set up between zfssnap@localhost and remuser@remhost
33
44
4. zfs allow done for remuser on remhost
34
45
(see http://mail.opensolaris.org/pipermail/zfs-auto-snapshot/2009-November/000198.html
35
46
for guidance on #2-4; you may need to also allow further permissions such as
36
47
sharenfs, userprop, hold, etc.)
37
48
5. an initial (full) zfs send/receive done so that remhost has the fs we
38
- are backing up, and the associated snapshots -- something like:
49
+ are backing up, and the associated snapshots -- something like:
39
50
zfs send -R $POOL/$FS@zfs-auto-snap_daily-(latest) | ssh $REMUSER@$REMHOST zfs recv -dvF $REMPOOL
51
+ Note: 'zfs send -R' will send *all* snapshots associated with a dataset, so
52
+ if you wish to purge old snapshots, do that first.
40
53
6. zfs allow any additional permissions needed, to fix any errors produced in step 5
41
54
7. configure the tag/prop/remuser/remhost/rempool variables in this script or in a config file
42
- (and update the CFG=... line accordingly)
43
55
8. zfs set $PROP={ fullpath | basename } pool/fs
44
- for each FS or volume you wish to back up.
56
+ for each FS or volume you wish to back up.
45
57
46
58
PROPERTY VALUES:
47
59
Given the hierarchy pool/a/b,
@@ -59,8 +71,15 @@ It's probably best to do a dry-run first (zfs recv -ndvF).
59
71
60
72
Note: I use daily snapshots in these manual send/recv examples because
61
73
it is less likely that the snapshot you are using will be rotated out
62
- in the middle of a send. Also, ZFS will send all snapshots for a given
63
- filesystem before sending any for its children.
74
+ in the middle of a send. Also, note that ZFS will send all snapshots for a
75
+ given filesystem before sending any for its children, rather than going in
76
+ global date order.
77
+
78
+ Alternatively, use a different tag (e.g. weekly) that still has common
79
+ snapshots, possibly in combination with the -r option (Nth most recent) to
80
+ avoid short-lived snapshots (e.g. hourly) being rotated out in the middle
81
+ of your sync. This is a good use case for an alternate configuration file.
82
+
64
83
65
84
PROCEDURE:
66
85
* find newest local hourly snapshot
0 commit comments