prepare backups better

This commit is contained in:
teldra 2021-04-12 16:27:29 +02:00
parent 419f7e235e
commit 16494e168c
2 changed files with 36 additions and 2 deletions

View File

@ -82,19 +82,52 @@ if [[ ! ${cfg[fde_key_store]} == "none" ]]; then
echo "fi" >> /etc/runit/core-services/99-changepwuser.sh
fi
mkdir -p /var/lib/backup/quelle/{rootfs,home}
echo "transaction_log /var/log/btrbk.log" > /etc/btrbk/btrbk.conf
echo "lockfile /tmp/btrbk.lock" >> /etc/btrbk/btrbk.conf
echo "incremental yes" >> /etc/btrbk/btrbk.conf
echo "btrfs_commit_delete after" >> /etc/btrbk/btrbk.conf
echo "timestamp_format long" >> /etc/btrbk/btrbk.conf
echo "noauto yes" >> /etc/btrbk/btrbk.conf
echo "volume /var/lib/backup/quelle/" >> /etc/btrbk/btrbk.conf
if [[ ! ${cfg[fde_key_store]} == "once" ]]; then
mkdir -p /var/lib/backup/quelle/boot
echo "volume /var/lib/backup/quelle/boot" >> /etc/btrbk/btrbk.conf
echo " group snapshot all" >> /etc/btrbk/btrbk.conf
echo " snapshot_dir snapshot" >> /etc/btrbk/btrbk.conf
echo " snapshot_preserve_min 4h" >> /etc/btrbk/btrbk.conf
echo " snapshot_preserve no" >> /etc/btrbk/btrbk.conf
echo " subvolume void" >> /etc/btrbk/btrbk.conf
fi
echo "volume /var/lib/backup/quelle/rootfs" >> /etc/btrbk/btrbk.conf
echo " group snapshot all" >> /etc/btrbk/btrbk.conf
echo " snapshot_dir snapshot" >> /etc/btrbk/btrbk.conf
echo " snapshot_preserve_min 4h" >> /etc/btrbk/btrbk.conf
echo " snapshot_preserve no " >> /etc/btrbk/btrbk.conf
echo " subvolume void-rootfs" >> /etc/btrbk/btrbk.conf
echo " subvolume home" >> /etc/btrbk/btrbk.conf
if [[ ! ${cfg[fde_key_store]} == "once" ]]; then
mkdir -p /var/lib/backup/ziel/void
echo "volume /var/lib/backup/quelle/boot" >> /etc/btrbk/btrbk.conf
echo " group backup all" >> /etc/btrbk/btrbk.conf
echo " snapshot_dir backup" >> /etc/btrbk/btrbk.conf
echo " snapshot_preserve_min 4h" >> /etc/btrbk/btrbk.conf
echo " snapshot_preserve no" >> /etc/btrbk/btrbk.conf
echo " target_preserve_min latest" >> /etc/btrbk/btrbk.conf
echo " target_preserve 20d 10w 2m" >> /etc/btrbk/btrbk.conf
echo " subvolume void" >> /etc/btrbk/btrbk.conf
echo " target send-receive /var/lib/backup/ziel/void/boot" >> /etc/btrbk/btrbk.conf
fi
echo "volume /var/lib/backup/quelle/rootfs" >> /etc/btrbk/btrbk.conf
echo " group backup all" >> /etc/btrbk/btrbk.conf
echo " snapshot_dir backup" >> /etc/btrbk/btrbk.conf
echo " snapshot_preserve_min 4h" >> /etc/btrbk/btrbk.conf
echo " snapshot_preserve no" >> /etc/btrbk/btrbk.conf
echo " target_preserve_min latest" >> /etc/btrbk/btrbk.conf
echo " target_preserve 20d 10w 2m" >> /etc/btrbk/btrbk.conf
echo " subvolume rootfs" >> /etc/btrbk/btrbk.conf
echo " target send-receive /var/lib/backup/ziel/void/rootfs" >> /etc/btrbk/btrbk.conf
echo " subvolume home" >> /etc/btrbk/btrbk.conf
echo " target send-receive /var/lib/backup/ziel/void/homefs" >> /etc/btrbk/btrbk.conf
mkdir -p /var/spool/cron/
echo "0 */2 * * * /usr/bin/btrbk -q run snapshot" >> /var/spool/cron/root

View File

@ -101,9 +101,10 @@ mkdir -p "${dest}/snapshot" "${dest}/backup"
umount "${dest}"
mount "/dev/mapper/voidvg.${diskid}-root" "${dest}" -o subvol=void-rootfs
for i in boot home dev proc sys tmp etc var/lib/backup/quelle var/db; do mkdir -p "${dest}/${i}"; done
for i in boot home dev proc sys tmp etc var/lib/backup/quelle/rootfs var/db; do mkdir -p "${dest}/${i}"; done
mount "/dev/mapper/voidvg.${diskid}-root" "${dest}"/home -o subvol=home
if [[ "${cfg[fde_key_store]}" == "once" ]]; then
mkdir -p "${dest}/var/lib/backup/quelle/boot"
mkfs.btrfs -q -f "${target_boot}"
mount "${target_boot}" "${dest}/boot"
fi