Fix prune options

This commit is contained in:
GRMrGecko 2022-12-30 02:24:47 -06:00
parent 3d381297f2
commit 5886973eed

View File

@ -17,6 +17,9 @@ export BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes
export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
export BORG_CHECK_I_KNOW_WHAT_I_AM_DOING=NO export BORG_CHECK_I_KNOW_WHAT_I_AM_DOING=NO
export BORG_DELETE_I_KNOW_WHAT_I_AM_DOING=NO export BORG_DELETE_I_KNOW_WHAT_I_AM_DOING=NO
# Set to empty string to disable pruning.
PRUNE_OPTIONS="--keep-daily 7 --keep-weekly 4 --keep-monthly 6"
for IMAGE in $IMAGES; do for IMAGE in $IMAGES; do
# Export volume to borg backup. # Export volume to borg backup.
@ -32,19 +35,19 @@ for IMAGE in $IMAGES; do
exit 1 exit 1
fi fi
# If you want to prune backups, you can set the prune options. # Prune if options are configured.
if [ -n "$PRUNE_OPTIONS" ]; then
echo "Pruning backups for $IMAGE" echo "Pruning backups for $IMAGE"
borg prune --list \ borg prune --list \
--show-rc \ --show-rc \
--glob-archives "$IMAGE-*" \ --glob-archives "$IMAGE-*" \
--keep-daily 7 \ $PRUNE_OPTIONS
--keep-weekly 4 \
--keep-monthly 6
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed prune $IMAGE" echo "Failed to prune $DOMAIN"
exit 1 exit 1
fi fi
fi
done done
# I save the status in a temporary file so I can error out and exit if a failure occurs. # I save the status in a temporary file so I can error out and exit if a failure occurs.