1
0
Fork 0

Compare commits

..

No commits in common. "3c15c5a9f50a5ed40547f8f85137d92d49c1107f" and "ce261fa71ffca1732584a45d85e037f6e62a07c6" have entirely different histories.

View file

@ -2,14 +2,11 @@
# Use setcap'd binary in home directory # Use setcap'd binary in home directory
#PATH="/home/restic/bin/:$PATH" #PATH="/home/restic/bin/:$PATH"
#Not necessary anymore : binary in /usr/bin setcap'd # Now uses binary in /usr/bin, which is also setcap'd
backup_origin="/backups/restic" backup_origin="/backups/restic"
backup_container="central-backup" backup_container="central-backup"
mail_sender='"Name""<sender@example.com>"'
mail_recipients="first@example.com,second@example.com"
if [[ -z "$1" || "$1" != "daily" && "$1" != "weekly" && "$1" != "monthly" ]]; then if [[ -z "$1" || "$1" != "daily" && "$1" != "weekly" && "$1" != "monthly" ]]; then
echo "Usage : backup [daily|weekly|monthly]" echo "Usage : backup [daily|weekly|monthly]"
exit 1 exit 1
@ -67,19 +64,6 @@ if [ $? -ne 0 ]; then
error_message="$error_message""$(cat backup_output.log)" error_message="$error_message""$(cat backup_output.log)"
fi 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 if [ -z "$error_message" ]; then
restic check --verbose > check_output.log 2>&1 restic check --verbose > check_output.log 2>&1
fi fi
@ -92,6 +76,14 @@ fi
# Clean up and remove old backups # Clean up and remove old backups
rm -rf temp/* 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 if [ -n "$error_message" ]; then
echo -e "$error_message" | mail -aFrom:"$mail_sender" -s "[$(uname -n)] ⚠️ Backup error $(date +%D-%Hh%M)" "$mail_recipients" echo -e "$error_message" | mail -aFrom:"$mail_sender" -s "[$(uname -n)] ⚠️ Backup error $(date +%D-%Hh%M)" "$mail_recipients"