Run prune before checking the backup repository
This commit is contained in:
parent
9efacf4f8c
commit
3c15c5a9f5
1 changed files with 14 additions and 12 deletions
|
@ -70,26 +70,28 @@ fi
|
|||
# Sleep to allow time for propagation
|
||||
sleep 60
|
||||
|
||||
# Remove old and stale data
|
||||
if [ -z "$error_message" ]; then
|
||||
restic check --verbose > check_output.log 2>&1
|
||||
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 check failed ! See log below.\n"
|
||||
error_message="$error_message""Backup purge will not be run.\n\n"
|
||||
error_message="$error_message""$(cat check_output.log)"
|
||||
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
|
||||
if [ $? -ne 0 ]; then
|
||||
error_message="Restic check failed ! See log below.\n"
|
||||
error_message="$error_message""Backup purge will not be run.\n\n"
|
||||
error_message="$error_message""$(cat check_output.log)"
|
||||
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"
|
||||
|
|
Loading…
Add table
Reference in a new issue