From 44820bdd75d86bf964ef02b37c38cceeb40be529 Mon Sep 17 00:00:00 2001 From: Eric Renfro Date: Fri, 2 Aug 2024 15:54:47 -0400 Subject: [PATCH] Update backup script to start a new backup, but replace the old --- gentoo-backup.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gentoo-backup.sh b/gentoo-backup.sh index 7eb7da5..98df377 100755 --- a/gentoo-backup.sh +++ b/gentoo-backup.sh @@ -9,6 +9,7 @@ fi pushd /var/backup &>/dev/null || exit 2 +echo "Creating stage4 backup in /var/backup/$bhost-stage4.zst" mkstage4 -s -l -q -C zst \ -e "/var/lib/containers/*" \ -e "/var/lib/machines/*" \ @@ -16,6 +17,16 @@ mkstage4 -s -l -q -C zst \ -e "/var/lib/libvirt/*" \ -e "/var/cache/binpkgs/*" \ -e "/home/*/*" \ - "$bhost-stage4" + "$bhost-stage4-$bdate" + +if [[ "$?" -ne 0 ]]; then + echo "ERROR: Backup failure" + exit 1 +else + if [[ -f "/var/backup/$bhost-stage4.zst" ]]; then + rm -f "/var/backup/$bhost-stage4.zst" + fi + mv "/var/backup/$bhost-stage4-$bdate.zst" "/var/backup/$bhost-stage4.zst" +fi popd &>/dev/null || exit 2