Compare commits
3 commits
ce261fa71f
...
3c15c5a9f5
Author | SHA1 | Date | |
---|---|---|---|
3c15c5a9f5 | |||
9efacf4f8c | |||
a278fdd40a |
1 changed files with 21 additions and 13 deletions
|
@ -2,11 +2,14 @@
|
||||||
|
|
||||||
# Use setcap'd binary in home directory
|
# Use setcap'd binary in home directory
|
||||||
#PATH="/home/restic/bin/:$PATH"
|
#PATH="/home/restic/bin/:$PATH"
|
||||||
# Now uses binary in /usr/bin, which is also setcap'd
|
#Not necessary anymore : binary in /usr/bin 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
|
||||||
|
@ -64,6 +67,19 @@ 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
|
||||||
|
@ -76,14 +92,6 @@ 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"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue