diff --git a/backup.sh b/backup.sh index 2187c31..809ebb9 100755 --- a/backup.sh +++ b/backup.sh @@ -31,18 +31,17 @@ logLast "AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}" # Do not save full backup log to logfile but to backup-last.log restic backup /data ${RESTIC_JOB_ARGS} --tag=${RESTIC_TAG?"Missing environment variable RESTIC_TAG"} >> ${lastLogfile} 2>&1 -rc=$? +backupRC=$? logLast "Finished backup at $(date)" -if [[ $rc == 0 ]]; then - echo "Backup Successfull" +if [[ $backupRC == 0 ]]; then + echo "Backup Successfull" else - echo "Backup Failed with Status ${rc}" + echo "Backup Failed with Status ${backupRC}" restic unlock copyErrorLog - exit 1 fi -if [ -n "${RESTIC_FORGET_ARGS}" ]; then +if [[ $backupRC == 0 ]] && [ -n "${RESTIC_FORGET_ARGS}" ]; then echo "Forget about old snapshots based on RESTIC_FORGET_ARGS = ${RESTIC_FORGET_ARGS}" restic forget ${RESTIC_FORGET_ARGS} >> ${lastLogfile} 2>&1 rc=$?