packer-builds

Packer Builds for LXC and Libvirt
git clone https://git.in0rdr.ch/packer-builds.git
Log | Files | Refs | Pull requests |Archive | README

commit 0b02230cc865b1ba320d57cfaf4138c169bdf903
parent 3dac0a6ed1c8af0a7098c31aed5e2c32492b61fa
Author: Andreas Gruhler <agruhl@gmx.ch>
Date:   Sun, 23 Feb 2025 08:27:24 +0100

feat(borg): readonly files during backup

Diffstat:
Mscripts/borg-backup.sh | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/borg-backup.sh b/scripts/borg-backup.sh @@ -53,7 +53,6 @@ cat <<EOF > "$PATTERNSFILE" P sh # A root path starts with the prefix R, followed by a path R /host-nfs -R /host-srv EOF # Install systemd service unit @@ -64,8 +63,13 @@ Description=Create a backup with borg [Service] Type=oneshot EnvironmentFile=/root/.config/borg/config +# prevent file modifications during backup +# borg error "file changed while we read it!: backup error" +ExecStart=/usr/bin/chattr -R +i /host-nfs ExecStart=/usr/local/bin/borg create -v --stats --compression lz4 {hostname}-{now:%%Y%%m%%dT%%H%%M} --patterns-from "$PATTERNSFILE" --exclude-caches --chunker-params fixed,4096 ExecStart=/usr/local/bin/borg prune -v --list --match-archives '{hostname}-*' --keep-daily=7 --keep-weekly=4 --keep-monthly=12 +# unlock +ExecStart=/usr/bin/chattr -R -i /host-nfs [Install] WantedBy=default.target @@ -78,7 +82,7 @@ Description=Create a backup with borg [Timer] Unit=borg-backup.service -OnCalendar=*-*-* 11:03:00 +OnCalendar=*-*-* 01:03:00 [Install] WantedBy=timers.target