Skip to content

Commit

Permalink
Pass list of created backups to postbackupscript
Browse files Browse the repository at this point in the history
  • Loading branch information
assistcontrol committed Aug 25, 2019
1 parent 3743c91 commit 90598bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
16 changes: 12 additions & 4 deletions acts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions acts.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 90598bd

Please sign in to comment.