forked from msimerson/Mail-Toaster-6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovision-rsnapshot.sh
executable file
·65 lines (54 loc) · 1.34 KB
/
provision-rsnapshot.sh
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
#!/bin/sh
# shellcheck disable=1091
. mail-toaster.sh || exit
export JAIL_START_EXTRA=""
export JAIL_CONF_EXTRA=""
install_rsnapshot()
{
tell_status "installing rsnapshot"
stage_pkg_install rsnapshot coreutils || exit
}
configure_rsnapshot()
{
local _pdir="$STAGE_MNT/usr/local/etc/periodic"
for p in daily weekly monthly
do
if [ ! -d "$_pdir/$p" ]; then
tell_status "creating $_pdir/$p"
mkdir -p "$_pdir/$p" || exit
fi
if [ ! -f "$_pdir/$p/rsnapshot" ]; then
tell_status "installing $p periodic task"
tee "$_pdir/$p/rsnapshot" <<EO_RSNAP
/usr/local/bin/rsnapshot -c /data/etc/rsnapshot.conf $p
EO_RSNAP
chmod 755 "$_pdir/$p/rsnapshot"
fi
done
for d in etc snaps
do
if [ ! -d "$ZFS_DATA_MNT/rsnapshot/$d" ]; then
mkdir "$ZFS_DATA_MNT/rsnapshot/$d"
fi
done
if [ ! -f "$ZFS_DATA_MNT/rsnapshot/etc/rsnapshot.conf" ]; then
tell-status "installing default $ZFS_DATA_MNT/etc/rsnapshot.conf"
cp "$STAGE_MNT/usr/local/etc/rsnapshot.conf.default" "$ZFS_DATA_MNT/rsnapshot/etc/rsnapshot.conf"
fi
}
start_rsnapshot()
{
echo "rsnapshot is triggered by periodic, which is run by cron"
}
test_rsnapshot()
{
echo "hrmm, how to test?"
}
base_snapshot_exists || exit
create_staged_fs rsnapshot
start_staged_jail rsnapshot
install_rsnapshot
configure_rsnapshot
start_rsnapshot
test_rsnapshot
promote_staged_jail rsnapshot