From dedc5406b8b8c200eb4d20b040f56b5f0ffb197b Mon Sep 17 00:00:00 2001 From: Simon L Date: Sun, 3 Apr 2022 12:36:49 +0200 Subject: [PATCH] improve rsyncbackup script (#2269) Signed-off-by: szaimen --- not-supported/borgbackup.sh | 10 +++++----- not-supported/rsyncbackup.sh | 36 ++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/not-supported/borgbackup.sh b/not-supported/borgbackup.sh index 7e80396e..b8597430 100644 --- a/not-supported/borgbackup.sh +++ b/not-supported/borgbackup.sh @@ -197,6 +197,11 @@ then done fi +# Export default values +export BORG_PASSPHRASE="$ENCRYPTION_KEY" +export BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes +export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes + # Skip daily backup creation if needed if [ -z "$SKIP_DAILY_BACKUP_CREATION" ] then @@ -372,11 +377,6 @@ Please don't restart or shutdown your server until then!" # https://iwalton.com/wiki/#[[Backup%20Script]] # https://decatec.de/linux/backup-strategie-fuer-linux-server-mit-borg-backup/ - # Export default values - export BORG_PASSPHRASE="$ENCRYPTION_KEY" - export BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes - export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes - # Log Borg version borg --version diff --git a/not-supported/rsyncbackup.sh b/not-supported/rsyncbackup.sh index 50fad396..2b6ee415 100644 --- a/not-supported/rsyncbackup.sh +++ b/not-supported/rsyncbackup.sh @@ -94,6 +94,14 @@ get_expiration_time() { exec > >(tee -i "$LOG_FILE") exec 2>&1 +# Send mail that backup was started +if ! send_mail "Off-shore backup started!" "You will be notified again when the backup is finished! +Please don't restart or shutdown your server until then!" +then + notify_admin_gui "Off-shore backup started!" "You will be notified again when the backup is finished! +Please don't restart or shutdown your server until then!" +fi + # Start backup inform_user "$IGreen" "Off-shore backup started! $CURRENT_DATE_READABLE" @@ -133,16 +141,6 @@ then send_error_mail "Not even one daily backup was successfully created. Please wait for that first." fi -# Check daily backup -rm -f /tmp/DAILY_BACKUP_CHECK_SUCCESSFUL -export SKIP_DAILY_BACKUP_CREATION=1 -bash "$SCRIPTS/daily-borg-backup.sh" -if ! [ -f "/tmp/DAILY_BACKUP_CHECK_SUCCESSFUL" ] -then - send_error_mail "Daily backup check failed!" \ - "Backup check was unsuccessful! $(date +%T)" -fi - # Prepare backup repository inform_user "$ICyan" "Mounting the daily backup drive..." if ! [ -d "$BACKUP_SOURCE_DIRECTORY" ] @@ -165,6 +163,16 @@ then fi fi +# Check daily backup +rm -f /tmp/DAILY_BACKUP_CHECK_SUCCESSFUL +export SKIP_DAILY_BACKUP_CREATION=1 +bash "$SCRIPTS/daily-borg-backup.sh" +if ! [ -f "/tmp/DAILY_BACKUP_CHECK_SUCCESSFUL" ] +then + send_error_mail "Daily backup check failed!" \ + "Backup check was unsuccessful! $(date +%T)" +fi + # Test if btrfs volume if grep " $BACKUP_MOUNTPOINT " /etc/mtab | grep -q btrfs then @@ -178,14 +186,6 @@ then done fi -# Send mail that backup was started -if ! send_mail "Off-shore backup started!" "You will be notified again when the backup is finished! -Please don't restart or shutdown your server until then!" -then - notify_admin_gui "Off-shore backup started!" "You will be notified again when the backup is finished! -Please don't restart or shutdown your server until then!" -fi - # Check if pending snapshot is existing and cancel the backup in this case. if does_snapshot_exist "NcVM-snapshot-pending" then