-
Notifications
You must be signed in to change notification settings - Fork 0
/
900-snapper.sh
executable file
·62 lines (50 loc) · 1.65 KB
/
900-snapper.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
#!/bin/sh
SNAPSHOT_DIR=/.snapshots
UPDATEDB_CONF=/etc/updatedb.conf
SNAPPER_CONFIG=/etc/snapper/configs/root
# Fixing .snapshots subvolume permissions
fix_snapshots_permissions()
{
printf "\e[1;34m%s\e[0m\n" "fixing .snapshots subvolume permissions"
umount "$SNAPSHOT_DIR"
rm -r "$SNAPSHOT_DIR"
snapper --no-dbus -c root create-config /
btrfs subvolume delete "$SNAPSHOT_DIR"
mkdir -p "$SNAPSHOT_DIR"
mount -a
chmod 750 "$SNAPSHOT_DIR"
chmod a+rx "$SNAPSHOT_DIR"
chown :wheel "$SNAPSHOT_DIR"
printf "\e[1;32m%s\e[0m\n" "Done!"
}
# Configuring root snapper config
configure_snapper()
{
printf "\e[1;34m%s\e[0m\n" "configuring root snapper config"
sed -i -e '10s/.*/QGROUP="1\/0"/' \
-e '22s/.*/ALLOW_GROUPS="wheel"/' \
-e '39s/.*/NUMBER_LIMIT="2-10"/' \
-e '40s/.*/NUMBER_LIMIT_IMPORTANT="4-10"/' \
-e '44s/.*/TIMELINE_CREATE="no"/' \
-e '51s/.*/TIMELINE_LIMIT_HOURLY="10"/' \
-e '52s/.*/TIMELINE_LIMIT_DAILY="10"/' \
-e '53s/.*/TIMELINE_LIMIT_WEEKLY="0"/' \
-e '54s/.*/TIMELINE_LIMIT_MONTHLY="10"/' \
-e '55s/.*/TIMELINE_LIMIT_YEARLY="10"/' "$SNAPPER_CONFIG"
printf "\e[1;32m%s\e[0m\n" "Done!"
}
# Configuring mlocate to exclude snapshots from updatedb
configure_mlocate()
{
printf "\e[1;34m%s\e[0m\n" "configuring mlocate to exclude snapshots from updatedb"
if [ ! -f "$UPDATEDB_CONF".bak ]; then
cp "$UPDATEDB_CONF" "$UPDATEDB_CONF".bak && printf "\e[1;36m%s\e[0m\n" "$UPDATEDB_CONF backed up"
else
printf "\e[1;36m%s\e[0m\n" "$UPDATEDB_CONF already backed up"
fi
sed -i '3s/.*/PRUNENAMES = ".git .hg .svn .snapshots"/' "$UPDATEDB_CONF"
printf "\e[1;32m%s\e[0m\n" "Done!"
}
fix_snapshots_permissions
configure_snapper
configure_mlocate