fixes
This commit is contained in:
parent
69068e0c22
commit
12c44253c5
|
@ -5,147 +5,45 @@ if [ "${UID}" -ne "0" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
infos() {
|
infos() {
|
||||||
echo "Durch automatische Snapshots wird dein System regelmässig"
|
echo "Snapshots sind Kopien der Dateien die keinen zusätzlichen Platz"
|
||||||
echo "(zur Zeit alle zwei Stunden), ohne mehr Platz"
|
echo "benötigen."
|
||||||
echo "zu verbrauchen, gedoppelt."
|
echo "Es wird bei jedem Update vom Betriebsystem ein Snapshot angelegt."
|
||||||
echo "Dieses hilft zb. gegen unbeabsichtigtes löschen von Dateien."
|
echo "So ist das Betriebssystem auch bei Problemen bootbar."
|
||||||
echo "Du kannst aktivieren, das sie regelmässig gemacht werden."
|
echo "Optional kann jede Stunde ein Snapshot der persönlichen Daten"
|
||||||
echo "Es ist optional, Snapshots auch für privaten Daten zu aktivieren."
|
echo "angelegt werden. Dann verliert man bei versehentlichem löschen"
|
||||||
echo "Achtung, Daten werden dadurch erst sehr verzögert gelöscht!"
|
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'
|
||||||
config() {
|
|
||||||
infos
|
|
||||||
test -f "/etc/void-snapshot.cfg" || touch "/etc/void-snapshot.cfg"
|
|
||||||
while read -p "Regelmässige Snapshots aktivieren? [Y/n] " answer; do
|
|
||||||
test -z "${answer}" && answer="y"
|
|
||||||
case "${answer}" in
|
|
||||||
y*|Y*|j*|J*)
|
|
||||||
if ! grep -q "AUTO" "/etc/void-snapshot.cfg"; then
|
|
||||||
echo "AUTO=true" >> "/etc/void-snapshot.cfg"
|
|
||||||
fi
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
n*|N*)
|
|
||||||
if grep -q "AUTO" "/etc/void-snapshot.cfg"; then
|
|
||||||
sed -i '/AUTO/d' "/etc/void-snapshot.cfg"
|
|
||||||
fi
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
*) echo "Antwort nicht eindeutig." ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
answer=""
|
|
||||||
while read -p "Möchtest du das System automatisch Snapshotten? [Y/n] " answer; do
|
|
||||||
test -z "${answer}" && answer="y"
|
|
||||||
case "${answer}" in
|
|
||||||
y*|Y*|j*|J*)
|
|
||||||
if ! grep -q "SYSTEMFS" "/etc/void-snapshot.cfg"; then
|
|
||||||
echo "SYSTEMFS=true" >> "/etc/void-snapshot.cfg"
|
|
||||||
fi
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
n*|N*)
|
|
||||||
if grep -q "SYSTEMFS" "/etc/void-snapshot.cfg"; then
|
|
||||||
sed -i '/SYSTEMFS/d' "/etc/void-snapshot.cfg"
|
|
||||||
fi
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Antwort nicht eindeutig." ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
answer=""
|
|
||||||
while read -p "Möchtest du deine Privaten Daten automatisch Snapshotten? [Y/n] " answer; do
|
|
||||||
test -z "${answer}" && answer="y"
|
|
||||||
case "${answer}" in
|
|
||||||
y*|Y*|j*|J*)
|
|
||||||
if ! grep -q "HOMEFS" "/etc/void-snapshot.cfg"; then
|
|
||||||
echo "HOMEFS=true" >> "/etc/void-snapshot.cfg"
|
|
||||||
fi
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
n*|N*)
|
|
||||||
if grep -q "HOMEFS" "/etc/void-snapshot.cfg"; then
|
|
||||||
sed -i '/HOMEFS/d' "/etc/void-snapshot.cfg"
|
|
||||||
fi
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
*) echo "Antwort nicht eindeutig." ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cron=""
|
cron=""
|
||||||
update=""
|
update=""
|
||||||
for i in $@; do
|
case $1 in
|
||||||
case $i in
|
update)
|
||||||
update)
|
update=1
|
||||||
update=1
|
word="update"
|
||||||
word="update"
|
;;
|
||||||
SYSTEM=1
|
cron)
|
||||||
;;
|
cron=1
|
||||||
config)
|
word="regular"
|
||||||
config
|
;;
|
||||||
exit
|
*)
|
||||||
;;
|
info
|
||||||
cron)
|
echo "Falscher aufruf"
|
||||||
cron=1
|
exit
|
||||||
word="regular"
|
;;
|
||||||
;;
|
esac
|
||||||
*)
|
|
||||||
arr+=( "$i" )
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
for i in "${arr[@]}"; do
|
|
||||||
case $i in
|
|
||||||
home)
|
|
||||||
HOMEFS=1
|
|
||||||
MANUAL=1
|
|
||||||
word="manual"
|
|
||||||
;;
|
|
||||||
system)
|
|
||||||
SYSTEMFS=1
|
|
||||||
MANUAL=1
|
|
||||||
word="manual"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo unknow word $i
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ "$#" -eq "0" ]; then
|
if [ "$#" -eq "0" ]; then
|
||||||
word="manual"
|
info
|
||||||
|
echo "Falscher aufruf"
|
||||||
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cfg="/etc/btrbk/btrbk.conf.void"
|
cfg="/etc/btrbk/btrbk.conf.void"
|
||||||
if [ "${MANUAL}" ]; then
|
test -f /etc/void-snapshot.cfg && . /etc/void-snapshot.cfg
|
||||||
word=manual
|
|
||||||
elif [ -z "${MANUAL}" ] && [ -z "${update}" ]; then
|
|
||||||
if [ ! -f "/etc/void-snapshot.cfg" ]; then
|
|
||||||
if [ "${cron}" ]; then
|
|
||||||
echo "no config file found"
|
|
||||||
echo "create one with: snapshot config"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
config || exit
|
|
||||||
fi
|
|
||||||
. "/etc/void-snapshot.cfg"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "${AUTO}" ] && [ "${cron}" ]; then
|
if [ "${update}" ]; then
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${SYSTEMFS}" ]; then
|
|
||||||
SNAP_BOOT=1
|
|
||||||
if mountpoint -q /var/lib/backup/quelle/bootfs; then
|
if mountpoint -q /var/lib/backup/quelle/bootfs; then
|
||||||
mkdir -p "/var/lib/backup/quelle/bootfs/system/snapshots/${word}"
|
mkdir -p "/var/lib/backup/quelle/bootfs/system/snapshots/${word}"
|
||||||
if ! btrbk --config="${cfg}" --quiet run "${word}boot"; then
|
if ! btrbk --config="${cfg}" --quiet run "${word}boot"; then
|
||||||
|
@ -154,22 +52,22 @@ if [ "${SYSTEMFS}" ]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "/var/lib/backup/quelle/rootfs/system/snapshots/${word}"
|
mkdir -p "/var/lib/backup/quelle/rootfs/system/snapshots/${word}"
|
||||||
if ! btrbk --config="${cfg}" --quiet run "${word}root"; then
|
if ! btrbk --config="${cfg}" --quiet run "${word}root"; then
|
||||||
btrbk --config="${cfg}" --quiet clean "${word}root"
|
btrbk --config="${cfg}" --quiet clean "${word}root"
|
||||||
echo "fail: btrbk --config=${cfg} --quiet run ${word}root"
|
echo "fail: btrbk --config=${cfg} --quiet run ${word}root"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
fi
|
if [ "${update}" ]; then
|
||||||
|
if ! update-grub 2> /dev/null; then
|
||||||
if [ "${HOMEFS}" ] && [ -z "${update}" ]; then
|
echo update-grub failed
|
||||||
mkdir -p "/var/lib/backup/quelle/rootfs/system/snapshots/${word}"
|
fi
|
||||||
btrbk --config="${cfg}" --quiet run "${word}home"
|
fi
|
||||||
fi
|
elif [ "${cron}" ]; then
|
||||||
|
if [ "${REGULAR_SNAPSHOT_HOME}" ]; then
|
||||||
|
mkdir -p "/var/lib/backup/quelle/rootfs/system/snapshots/${word}"
|
||||||
if [ "${SNAP_BOOT}" ]; then
|
btrbk --config="${cfg}" --quiet run "${word}home"
|
||||||
if ! update-grub 2> /dev/null; then
|
|
||||||
echo update-grub failed
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -24,50 +24,27 @@ volume /var/lib/backup/quelle/rootfs
|
||||||
|
|
||||||
# Regular snapshots
|
# Regular snapshots
|
||||||
volume /var/lib/backup/quelle/bootfs
|
volume /var/lib/backup/quelle/bootfs
|
||||||
group regularboot cronstats regularstats allstats snapshotstats
|
group regularboot regularstats allstats snapshotstats
|
||||||
snapshot_dir system/snapshots/regular
|
snapshot_dir system/snapshots/regular
|
||||||
snapshot_preserve_min 4h
|
snapshot_preserve_min 4h
|
||||||
snapshot_preserve no
|
snapshot_preserve no
|
||||||
subvolume bootfs
|
subvolume bootfs
|
||||||
|
|
||||||
volume /var/lib/backup/quelle/rootfs
|
volume /var/lib/backup/quelle/rootfs
|
||||||
group regularroot cronstats regularstats allstats snapshotstats
|
group regularroot regularstats allstats snapshotstats
|
||||||
snapshot_dir system/snapshots/regular
|
snapshot_dir system/snapshots/regular
|
||||||
snapshot_preserve_min 4h
|
snapshot_preserve_min 4h
|
||||||
snapshot_preserve no
|
snapshot_preserve no
|
||||||
subvolume rootfs
|
subvolume rootfs
|
||||||
|
|
||||||
volume /var/lib/backup/quelle/rootfs
|
volume /var/lib/backup/quelle/rootfs
|
||||||
group regularhome cronstats regularstats allstats snapshotstats
|
group regularhome regularstats allstats snapshotstats
|
||||||
snapshot_dir system/snapshots/regular
|
snapshot_dir system/snapshots/regular
|
||||||
snapshot_preserve_min 4h
|
snapshot_preserve_min 4h
|
||||||
snapshot_preserve no
|
snapshot_preserve no
|
||||||
subvolume homefs
|
subvolume homefs
|
||||||
|
|
||||||
|
|
||||||
# Manual Snapshots
|
|
||||||
volume /var/lib/backup/quelle/bootfs
|
|
||||||
group manualboot manualstats allstats snapshotstats
|
|
||||||
snapshot_dir system/snapshots/manual
|
|
||||||
snapshot_preserve_min latest
|
|
||||||
snapshot_preserve no
|
|
||||||
subvolume bootfs
|
|
||||||
|
|
||||||
volume /var/lib/backup/quelle/rootfs
|
|
||||||
group manualroot manualstats allstats snapshotstats
|
|
||||||
snapshot_dir system/snapshots/manual
|
|
||||||
snapshot_preserve_min latest
|
|
||||||
snapshot_preserve no
|
|
||||||
subvolume rootfs
|
|
||||||
|
|
||||||
volume /var/lib/backup/quelle/rootfs
|
|
||||||
group manualhome manualstats allstats snapshotstats
|
|
||||||
snapshot_dir system/snapshots/manual
|
|
||||||
snapshot_preserve_min latest
|
|
||||||
snapshot_preserve no
|
|
||||||
subvolume homefs
|
|
||||||
|
|
||||||
|
|
||||||
# Backup
|
# Backup
|
||||||
volume /var/lib/backup/quelle/bootfs
|
volume /var/lib/backup/quelle/bootfs
|
||||||
group backupboot backupstats allstats
|
group backupboot backupstats allstats
|
||||||
|
@ -80,7 +57,7 @@ volume /var/lib/backup/quelle/bootfs
|
||||||
target send-receive /var/lib/backup/ziel/void/bootfs
|
target send-receive /var/lib/backup/ziel/void/bootfs
|
||||||
|
|
||||||
volume /var/lib/backup/quelle/rootfs
|
volume /var/lib/backup/quelle/rootfs
|
||||||
group backuproot backupstats allstats
|
group backup backupstats allstats
|
||||||
snapshot_dir system/backup
|
snapshot_dir system/backup
|
||||||
snapshot_preserve_min latest
|
snapshot_preserve_min latest
|
||||||
snapshot_preserve no
|
snapshot_preserve no
|
||||||
|
@ -90,7 +67,7 @@ volume /var/lib/backup/quelle/rootfs
|
||||||
target send-receive /var/lib/backup/ziel/void/rootfs
|
target send-receive /var/lib/backup/ziel/void/rootfs
|
||||||
|
|
||||||
volume /var/lib/backup/quelle/rootfs
|
volume /var/lib/backup/quelle/rootfs
|
||||||
group backuphome backupstats allstats
|
group backup backupstats allstats
|
||||||
snapshot_dir system/backup
|
snapshot_dir system/backup
|
||||||
snapshot_preserve_min latest
|
snapshot_preserve_min latest
|
||||||
snapshot_preserve no
|
snapshot_preserve no
|
||||||
|
|
|
@ -78,7 +78,7 @@ mkswap "/dev/mapper/voidvg.${diskid}-swap"
|
||||||
mount "/dev/mapper/voidvg.${diskid}-root" "${dest}"
|
mount "/dev/mapper/voidvg.${diskid}-root" "${dest}"
|
||||||
btrfs subvol create "${dest}/rootfs"
|
btrfs subvol create "${dest}/rootfs"
|
||||||
btrfs subvol create "${dest}/homefs"
|
btrfs subvol create "${dest}/homefs"
|
||||||
mkdir -p "${dest}/system/snapshots/{update,regular,manual}" "${dest}/system/backup"
|
mkdir -p "${dest}/system/snapshots/{update,regular}" "${dest}/system/backup"
|
||||||
|
|
||||||
umount "${dest}"
|
umount "${dest}"
|
||||||
mount "/dev/mapper/voidvg.${diskid}-root" "${dest}" -o subvol=rootfs
|
mount "/dev/mapper/voidvg.${diskid}-root" "${dest}" -o subvol=rootfs
|
||||||
|
@ -89,7 +89,7 @@ if [[ "${cfg[fde_key_store]}" == "once" ]]; then
|
||||||
mkfs.btrfs -q -f "${target_boot}"
|
mkfs.btrfs -q -f "${target_boot}"
|
||||||
mount "${target_boot}" "${dest}/boot"
|
mount "${target_boot}" "${dest}/boot"
|
||||||
btrfs subvol create "${dest}/boot/bootfs"
|
btrfs subvol create "${dest}/boot/bootfs"
|
||||||
mkdir -p "${dest}/boot/system/snapshots/{update,regular,manual}" "${dest}/boot/system/backup"
|
mkdir -p "${dest}/boot/system/snapshots/{update,regular}" "${dest}/boot/system/backup"
|
||||||
umount "${dest}/boot"
|
umount "${dest}/boot"
|
||||||
mount "${target_boot}" "${dest}/boot" -o subvol=bootfs
|
mount "${target_boot}" "${dest}/boot" -o subvol=bootfs
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -74,7 +74,7 @@ mkswap "/dev/mapper/voidvg.${diskid}-swap"
|
||||||
mount "/dev/mapper/voidvg.${diskid}-root" "${dest}"
|
mount "/dev/mapper/voidvg.${diskid}-root" "${dest}"
|
||||||
btrfs subvol create "${dest}/rootfs"
|
btrfs subvol create "${dest}/rootfs"
|
||||||
btrfs subvol create "${dest}/homefs"
|
btrfs subvol create "${dest}/homefs"
|
||||||
mkdir -p "${dest}/system/snapshots/{update,regular,manual}" "${dest}/system/backup"
|
mkdir -p "${dest}/system/snapshots/{update,regular}" "${dest}/system/backup"
|
||||||
|
|
||||||
umount "${dest}"
|
umount "${dest}"
|
||||||
mount "/dev/mapper/voidvg.${diskid}-root" "${dest}" -o subvol=rootfs
|
mount "/dev/mapper/voidvg.${diskid}-root" "${dest}" -o subvol=rootfs
|
||||||
|
@ -85,7 +85,7 @@ if [[ "${cfg[fde_key_store]}" == "once" ]]; then
|
||||||
mkfs.btrfs -q -f "${target_boot}"
|
mkfs.btrfs -q -f "${target_boot}"
|
||||||
mount "${target_boot}" "${dest}/boot"
|
mount "${target_boot}" "${dest}/boot"
|
||||||
btrfs subvol create "${dest}/boot/bootfs"
|
btrfs subvol create "${dest}/boot/bootfs"
|
||||||
mkdir -p "${dest}/boot/system/snapshots/{update,regular,manual}" "${dest}/boot/system/backup"
|
mkdir -p "${dest}/boot/system/snapshots/{update,regular}" "${dest}/boot/system/backup"
|
||||||
umount "${dest}/boot"
|
umount "${dest}/boot"
|
||||||
mount "${target_boot}" "${dest}/boot" -o subvol=bootfs
|
mount "${target_boot}" "${dest}/boot" -o subvol=bootfs
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue