-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzsnapshot
executable file
·72 lines (44 loc) · 1.45 KB
/
zsnapshot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh
# This script will rsync various directories to ZFS and snapshot them.
# (c) 2007 Chris Samuel
# This script is licensed under the GPL v3 license or later.
# http://www.gnu.org/copyleft/gpl.html
# First work out the datestamp to be used for all snapshots.
date=$(date +%Y%m%d-%H%M)
echo Snapshot will be labelled $date
# First mount our ZFS filesystems
zfs mount -a
sleep 5
if [ \! -f /srv/ZFS/etc/motd ]; then
echo "ZFS start failed!"
sleep 60
stop zfs
exit 1
fi
# Snapshot top level directories we care about.
for i in etc home; do
echo Processing $i
# If they don't exist then create them, turn on compression.
if [ ! -d /srv/ZFS/$i ]; then
zfs create ZFS/$i
zfs set compression=on ZFS/$i
zfs set snapdir=visible ZFS/$i
fi
time rsync --inplace --no-whole-file --delete-excluded --exclude .beagle --exclude .bibble --exclude .googleearth --exclude .thumbnails -a /$i/ /srv/ZFS/$i/
zfs snapshot ZFS/$i@$date
done
# Snapshot directories under /srv
for i in Subversion; do
echo Processing $i
# If they don't exist then create them, turn on compression.
if [ ! -d /srv/ZFS/$i ]; then
zfs create ZFS/$i
zfs set compression=on ZFS/$i
zfs set snapdir=visible ZFS/$i
fi
time rsync --inplace --no-whole-file --delete-excluded --exclude .beagle --exclude .bibble --exclude .googleearth --exclude .thumbnails -a /srv/$i/ /srv/ZFS/$i/
zfs snapshot ZFS/$i@$date
done
# Now unmount our ZFS filesystems
zfs umount -a
# All done!