2021-04-15 10:27:27 +02:00
|
|
|
#!/bin/bash
|
|
|
|
if [ "${UID}" -ne "0" ]; then
|
|
|
|
echo "Keine Rootrechte."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-05-07 18:52:50 +02:00
|
|
|
infos() {
|
2021-05-07 19:41:32 +02:00
|
|
|
echo "Snapshots sind Kopien der Dateien die keinen zusätzlichen Platz"
|
|
|
|
echo "benötigen."
|
|
|
|
echo "Es wird bei jedem Update vom Betriebsystem ein Snapshot angelegt."
|
2021-05-09 14:20:03 +02:00
|
|
|
echo "Es wird bei jede volle Stunde vom Betriebsystem ein Snapshot angelegt."
|
2021-05-07 19:41:32 +02:00
|
|
|
echo "So ist das Betriebssystem auch bei Problemen bootbar."
|
2021-05-09 14:20:03 +02:00
|
|
|
echo "Optional kann auch jede Stunde ein Snapshot der persönlichen Daten"
|
2021-05-07 19:41:32 +02:00
|
|
|
echo "angelegt werden. Dann verliert man bei versehentlichem löschen"
|
|
|
|
echo "maximal die Arbeit einer Stunde."
|
|
|
|
echo "Dafuer folgendes im Terminal ausführen:"
|
|
|
|
echo 'echo REGULAR_SNAPSHOT_HOME=1 | sudo tee /etc/void-snapshot.cfg'
|
2021-04-18 21:15:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cron=""
|
|
|
|
update=""
|
2021-05-07 19:41:32 +02:00
|
|
|
case $1 in
|
|
|
|
update)
|
|
|
|
update=1
|
|
|
|
word="update"
|
|
|
|
;;
|
|
|
|
cron)
|
|
|
|
cron=1
|
|
|
|
word="regular"
|
|
|
|
;;
|
|
|
|
*)
|
2021-05-07 23:13:24 +02:00
|
|
|
infos
|
2021-05-07 19:41:32 +02:00
|
|
|
exit
|
|
|
|
;;
|
|
|
|
esac
|
2021-04-18 11:38:18 +02:00
|
|
|
|
2021-05-07 18:52:50 +02:00
|
|
|
if [ "$#" -eq "0" ]; then
|
2021-05-07 23:13:24 +02:00
|
|
|
infos
|
2021-05-07 19:41:32 +02:00
|
|
|
exit
|
2021-04-18 21:15:25 +02:00
|
|
|
fi
|
|
|
|
|
2021-05-07 18:52:50 +02:00
|
|
|
cfg="/etc/btrbk/btrbk.conf.void"
|
2021-05-10 09:24:40 +02:00
|
|
|
test -f "/etc/btrbk/btrbk.conf" && cfg="/etc/btrbk/btrbk.conf"
|
2021-04-18 21:15:25 +02:00
|
|
|
|
2021-05-09 14:20:03 +02:00
|
|
|
if mountpoint -q /var/lib/backup/quelle/bootfs; then
|
|
|
|
mkdir -p "/var/lib/backup/quelle/bootfs/system/snapshots/${word}"
|
|
|
|
if ! btrbk --config="${cfg}" --quiet run "${word}boot"; then
|
|
|
|
btrbk --config="${cfg}" --quiet clean "${word}boot"
|
|
|
|
echo "fail: btrbk --config=${cfg} --quiet run ${word}boot"
|
2021-05-07 18:52:50 +02:00
|
|
|
exit
|
|
|
|
fi
|
2021-05-09 14:20:03 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p "/var/lib/backup/quelle/rootfs/system/snapshots/${word}"
|
|
|
|
if ! btrbk --config="${cfg}" --quiet run "${word}root"; then
|
|
|
|
btrbk --config="${cfg}" --quiet clean "${word}root"
|
|
|
|
echo "fail: btrbk --config=${cfg} --quiet run ${word}root"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! update-grub 2> /dev/null; then
|
|
|
|
echo update-grub failed
|
2021-05-10 10:47:40 +02:00
|
|
|
exit
|
2021-05-09 14:20:03 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${cron}" ]; then
|
|
|
|
test -f /etc/void-snapshot.cfg && . /etc/void-snapshot.cfg
|
2021-05-07 19:41:32 +02:00
|
|
|
if [ "${REGULAR_SNAPSHOT_HOME}" ]; then
|
|
|
|
mkdir -p "/var/lib/backup/quelle/rootfs/system/snapshots/${word}"
|
2021-05-10 10:47:40 +02:00
|
|
|
if ! btrbk --config="${cfg}" --quiet run "${word}home"; then
|
|
|
|
btrbk --config="${cfg}" --quiet clean "${word}home"
|
|
|
|
echo "fail: btrbk --config=${cfg} --quiet clean ${word}home"
|
|
|
|
exit
|
2021-05-10 13:02:30 +02:00
|
|
|
fi
|
2021-05-07 18:52:50 +02:00
|
|
|
fi
|
2021-04-18 15:52:09 +02:00
|
|
|
fi
|
2021-05-07 19:41:32 +02:00
|
|
|
|