From 90598bd5ef227290db9c0fcb1e9c4e585aa7e4de Mon Sep 17 00:00:00 2001 From: Adam Weinberger Date: Sun, 25 Aug 2019 11:32:35 -0600 Subject: [PATCH] Pass list of created backups to postbackupscript --- acts | 16 ++++++++++++---- acts.conf.sample | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/acts b/acts index ca9f98e..4e951f0 100755 --- a/acts +++ b/acts @@ -191,6 +191,7 @@ fi # PART 3: Backup backuprc=0 # Notice any failed backups +backuplist="" # Maintain list of successfully created archives for dir in $backuptargets; do log_debug "message=\"Starting backup of $dir\"" archive_starttime=$(date +%s) @@ -204,7 +205,9 @@ for dir in $backuptargets; do log_verbose "backup-start type=daily dir=/$dir name=$dailyarchive" # Uncontrolled expansion is bad, but we have little choice. See https://github.com/koalaman/shellcheck/wiki/Sc2086 # shellcheck disable=SC2086 - if ! output="$($tarsnap -c -f "$dailyarchive" -C / $tarsnapbackupoptions "$dir" 2>&1)"; then + if output="$($tarsnap -c -f "$dailyarchive" -C / $tarsnapbackupoptions "$dir" 2>&1)"; then + backuplist="$backuplist $dailyarchive" + else log_output=$(prettyprint log_output "$output") log_message "backup-error type=daily dir=$logdirname output=\"$log_output\"" backuprc=1 @@ -219,7 +222,9 @@ for dir in $backuptargets; do log_debug "message=\"Copying $logdirname daily archive to yearly archive\"" archive_starttime=$(date +%s) # shellcheck disable=SC2086 - if ! output="$($tarsnap -c -f "$yearlyarchive" $tarsnapbackupoptions "@@$dailyarchive" 2>&1)"; then + if output="$($tarsnap -c -f "$yearlyarchive" $tarsnapbackupoptions "@@$dailyarchive" 2>&1)"; then + backuplist="$backuplist $yearlyarchive" + else log_output=$(prettyprint log_output "$output") log_message "copy-error type=yearly output=\"$log_output\"" backuprc=1 @@ -233,7 +238,9 @@ for dir in $backuptargets; do log_debug "message=\"Copying $logdirname daily archive to monthly archive\"" archive_starttime=$(date +%s) # shellcheck disable=SC2086 - if ! output="$($tarsnap -c -f "$monthlyarchive" $tarsnapbackupoptions "@@$dailyarchive" 2>&1)"; then + if output="$($tarsnap -c -f "$monthlyarchive" $tarsnapbackupoptions "@@$dailyarchive" 2>&1)"; then + backuplist="$backuplist $yearlyarchive" + else log_output=$(prettyprint log_output "$output") log_message "copy-error type=monthly output=\"$log_output\"" backuprc=1 @@ -290,7 +297,8 @@ done if [ -n "$postbackupscript" ]; then if [ -x "$postbackupscript" ]; then log_verbose "run-postbackupscript script=$postbackupscript..." - $postbackupscript + # shellcheck disable=SC2086 + $postbackupscript $backuplist else die "acts-error message=\"postbackupscript $postbackupscript is not executable!\"" fi diff --git a/acts.conf.sample b/acts.conf.sample index 1d8dbd7..4871e6c 100644 --- a/acts.conf.sample +++ b/acts.conf.sample @@ -43,6 +43,7 @@ verbose=1 # postbackupscript # This script is run after acts is otherwise finished. Make sure it's executable. +# All created backups are passed as args # Default: unset #postbackupscript=/root/acts-post.sh