1
0
Fork 0

Run prune before checking the backup repository

This commit is contained in:
Teo-CD 2022-04-18 10:44:21 +01:00
parent 9efacf4f8c
commit 3c15c5a9f5

View file

@ -70,6 +70,16 @@ fi
# Sleep to allow time for propagation
sleep 60
# Remove old and stale data
if [ -z "$error_message" ]; then
restic forget --verbose --prune --group-by tag --tag "$1" --keep-last "$backup_count" > forget_output.log 2>&1
fi
if [ $? -ne 0 ]; then
error_message="Restic forget failed ! See log bellow.\n\n"
error_message="$error_message""$(cat forget_output.log)"
fi
# Check repository status
if [ -z "$error_message" ]; then
restic check --verbose > check_output.log 2>&1
fi
@ -82,14 +92,6 @@ fi
# Clean up and remove old backups
rm -rf temp/*
if [ -z "$error_message" ]; then
restic forget --verbose --prune --group-by tag --tag "$1" --keep-last "$backup_count" > forget_output.log 2>&1
fi
if [ $? -ne 0 ]; then
error_message="Restic forget failed ! See log bellow.\n\n"
error_message="$error_message""$(cat forget_output.log)"
fi
if [ -n "$error_message" ]; then
echo -e "$error_message" | mail -aFrom:"$mail_sender" -s "[$(uname -n)] ⚠️ Backup error $(date +%D-%Hh%M)" "$mail_recipients"