-
Notifications
You must be signed in to change notification settings - Fork 2
/
backup
executable file
·72 lines (60 loc) · 2.01 KB
/
backup
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/zsh
# Sichern aller aufgelisteten Rechner auf ein angestecktes Laufwerk
# your mountpoint for backsnap
BS_MOUNT=/mnt/BackSnap
# start of the uuid of your backup partition
BS_ID=03417033
# activate ssh-askpass for gui usage
export SSH_ASKPASS_REQUIRE="prefer"
# search for the backup device:
BS_UUID=$(lsblk -o uuid | grep -E $BS_ID)
# echo "UUID=$BS_UUID LEN=${#BS_UUID}"
[ ${#BS_UUID} -le 35 ] &&
echo "error: backup disk with UUID $BS_ID... is not connected" && exit
# mount backup device:
WAS_MOUNTED=$(mount | grep -E " $BS_MOUNT ")
# echo "was mounted=$WAS_MOUNTED"
[ ${#WAS_MOUNTED} -le 10 ] &&
echo "i need to mount $BS_UUID to $BS_MOUNT" &&
mount -t btrfs -o subvol=@BackSnap,compress=zstd:9 /dev/disk/by-uuid/$BS_UUID $BS_MOUNT
mount | grep -E " $BS_MOUNT " ||
{ echo "error: could not mount $BS_UUID to $BS_MOUNT" && exit }
function backup {
# This script needs to run in a terminal with sudo to get the grapical version !
backsnap -gtc -v=1 -a=12 $1 $BS_MOUNT/$2 || exit
# alternative cli-version is called:
# backsnap -tc -v=3 $1 $BS_MOUNT/$2 || exit
echo "OK"
}
# lokal sichern
backup / manjaro18
backup /home manjaro18.home
# server sichern
backup root@server:/ server
backup root@server:/home server.home
backup root@server:/srv server.srv
# jitsi sichern
backup root@jitsim1:/ jitsim1
backup root@jitsim1:/home jitsim1.home
backup root@jitsim1:/opt/hst jitsim1.hst
backup root@jitsim1:/opt/hugo jitsim1.hugo
# laptop sichern
backup root@notebook: notebook
backup root@notebook:/home notebook.home
# gast sichern
backup root@gast:/ gast
backup root@gast:/home gast.home
# timeshift sichern
backup root@timeshift:/ timeshift
backup root@timeshift:/home timeshift.home
# timeshift sichern mit Fehlermeldung weil Parameter 2 fehlt
# backup root@timeshift:/
# backup root@timeshift:/home
# Laufwerk unmounten:
sync
[ ${#WAS_MOUNTED} -le 10 ] &&
echo "i need to umount $BS_MOUNT" &&
umount $BS_MOUNT &&
sync
mount | grep -E " $BS_MOUNT "
echo "fertig mit den Backups"