Skip to content

Commit

Permalink
[Hotfix] Check Prune Stats
Browse files Browse the repository at this point in the history
Removed unsupported '--stats' option for the weekly check operation.
Also:
 - Improved BACKUP_NAME value possibilities by moving the messageMacrofier.
 - Added extra whitelines in output to improve readability by grouping operations for a common archive.
  • Loading branch information
Nuxij committed May 4, 2015
2 parents f5ff1be + 70956a5 commit cd2c797
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions backupld
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,22 @@
# Dependencies / Setup
set -o pipefail
. cpfb
messageMacrofier() {
echo "$(echo $@ | m4 \
-D name="$BACKUP_NAME" \
-D date="$TODAY_DATE" \
-D fail_count="$FAIL_COUNT" \
- \
)"
}

TODAY_DATE="$(date +%Y%m%d)"
FAIL_COUNT=0
LOG="$(mktemp /tmp/backupld_XXXXX)"
parseConfig "$1" || let FAIL_COUNT+=1

# Check backup_name specials
if [[ "$BACKUP_NAME" == "date" ]]; then
BACKUP_NAME="$TODAY_DATE"
fi
BACKUP_NAME="$(messageMacrofier $BACKUP_NAME)"

# Logic
createBackup() {
Expand Down Expand Up @@ -71,7 +78,7 @@ pruneBackup() {

checkBackup() {
echo "--- [Check $(date +%A)] Backup for $1::$2" | printMessage
attic check --stats "$BACKUP_HOST:$1.attic" 2>&1 | printMessage
attic check "$BACKUP_HOST:$1.attic" 2>&1 | printMessage
exitCode=$?
if [[ $exitCode -eq 0 ]]; then
echo "--- [Check] Completed successfully" | printMessage
Expand All @@ -93,6 +100,7 @@ checkEncryption() {

runBackups() {
echo "#### backupld - Starting ####" | printMessage
echo -en "\n" | printMessage
for dir in "${!LOCAL_BACKUP_DIRS[@]}"; do
local dirPath="$(echo ${LOCAL_BACKUP_DIRS[$dir]} | awk -F';' '{print $1}')"
if checkEncryption "$(echo ${LOCAL_BACKUP_DIRS[$dir]} | awk -F';' '{print $2}')"; then
Expand All @@ -106,6 +114,7 @@ runBackups() {
if [[ $(date +%u) -eq $BACKUP_CHECK_DAY ]]; then
checkBackup "$dir" "$dirPath"
fi
echo -en "\n" | printMessage
fi
done
if [[ "$FAIL_COUNT" -gt 0 ]]; then
Expand Down Expand Up @@ -239,13 +248,4 @@ printMessage() {
done
}

messageMacrofier() {
echo "$(echo $@ | m4 \
-D name="$BACKUP_NAME" \
-D date="$TODAY_DATE" \
-D fail_count="$FAIL_COUNT" \
- \
)"
}

runBackups

0 comments on commit cd2c797

Please sign in to comment.