Update backup script to start a new backup, but replace the old

This commit is contained in:
Eric Renfro 2024-08-02 15:54:47 -04:00
parent 45ec0d7a89
commit 44820bdd75
Signed by: psi-jack
SSH key fingerprint: SHA256:1TKB8Z257L8EHK8GWNxKgMhD8a+FAR+f+j3nnlcuNVM

View file

@ -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