Skip to content

Commit

Permalink
separate status on backup and catalog ops
Browse files Browse the repository at this point in the history
  • Loading branch information
per2jensen committed Feb 19, 2024
1 parent befa52b commit 4b16afa
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
20 changes: 17 additions & 3 deletions bin/dar-backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ DAR_ARCHIVE=""
ARCHIVEPATH=""
LOCAL_BACKUP_DIR=""
export EVERYTHING_OK=0 # report this at the end, will be set to 1 if something goes wrong
export BACKUP_OK=0
export CATALOG_OK=0
export CMD_DEBUG="n"
export CMD_USE_CATALOGS="n"
export VERBOSE="n"
Expand Down Expand Up @@ -146,7 +148,7 @@ if [[ "$USE_CATALOGS" == "y" || "$CMD_USE_CATALOGS" == "y" ]]; then
log_verbose "check if CATALOG: \"$MOUNT_POINT/$CATALOG\" exists"
if [[ ! -e "$MOUNT_POINT/$CATALOG" ]]; then
log_error "Catalog \"$CATALOG\" for backup definition \"$_CURRENT_BACKUPDEF\" is missing, continuing"
EVERYTHING_OK=1
CATALOG_OK=1
else
log_verbose "CATALOG: \"$CATALOG\" does exist"
fi
Expand Down Expand Up @@ -188,11 +190,23 @@ else
fi
fi
fi
if [[ "$EVERYTHING_OK" == "0" ]]; then

if [[ "$BACKUP_OK" == "0" ]]; then
log_success "Backup ended, all ok"
sendDiscordMsg "$SCRIPTNAME ended without errors"
else
sendDiscordMsg "ERROR: $SCRIPTNAME ended with errors"
fi

exit "$EVERYTHING_OK"
if [[ "$CATALOG_OK" == "0" ]]; then
log_success "Catalog operations ended ok"
else
log_error "Catalog operations had errors"
fi


if [[ "$BACKUP_OK" == "0" && "$CATALOG_OK" == "0" ]]; then
exit 0
else
exit 1
fi
20 changes: 10 additions & 10 deletions bin/dar-util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ diffBackupTestRestore () {
log "par2 repair data generated for \"${DAR_ARCHIVE}\", result: $RESULT"
else
log_error "par repair data not created for \"${DAR_ARCHIVE}\""
EVERYTHING_OK=1
BACKUP_OK=1
fi
}

Expand All @@ -265,7 +265,7 @@ backupTestRestore () {
log "par2 repair data generated for \"${DAR_ARCHIVE}\", result: $RESULT"
else
log_error "par repair data not created for \"${DAR_ARCHIVE}\""
EVERYTHING_OK=1
BACKUP_OK=1
fi
}

Expand Down Expand Up @@ -326,11 +326,11 @@ darBackup () {
"${SCRIPTDIRPATH}/manager.sh" --add-specific-archive "${DAR_ARCHIVE}" --local-backup-dir
if [[ $? != "0" ]]; then
log_error "archive \"${DAR_ARCHIVE}\" not added to it's catalog"
EVERYTHING_OK=1
CATALOG_OK=1
fi
fi
else
EVERYTHING_OK=1
BACKUP_OK=1
fi
exitCodeExpl "$_RESULT"
RESULT=$_RESULT
Expand Down Expand Up @@ -367,12 +367,12 @@ darDiffBackup () {
;;
*)
log_error "Some error were found while adding \"${DAR_ARCHIVE}\" to it's catalog"
EVERYTHING_OK=1
CATALOG_OK=1
;;
esac
fi
else
EVERYTHING_OK=1
BACKUP_OK=1
fi
exitCodeExpl "$_RESULT"
RESULT=$_RESULT
Expand All @@ -387,7 +387,7 @@ darTestBackup () {
dar -Q -t "${ARCHIVEPATH}"
RESULT=$?
if [[ $RESULT != "0" ]]; then
EVERYTHING_OK=1
BACKUP_OK=1
log_error "test of archive: ${DAR_ARCHIVE}, result: $RESULT"
fi
if [[ "$VERBOSE" == "y" ]]; then
Expand Down Expand Up @@ -450,13 +450,13 @@ darRestoreTest () {
dar -Q -x "$ARCHIVEPATH" -R "$RESTORE_DIR" -g "$TEST_RESTOREFILE" --fsa-scope none -B "$SCRIPTDIRPATH/../conf/defaults-rc"
RESULT=$?
if [[ $RESULT != "0" ]]; then
EVERYTHING_OK=1
BACKUP_OK=1
fi
else
dar -Q -x "$ARCHIVEPATH" -R "$RESTORE_DIR" -g "$TEST_RESTOREFILE" -B "$SCRIPTDIRPATH/../conf/defaults-rc"
RESULT=$?
if [[ $RESULT != "0" ]]; then
EVERYTHING_OK=1
BACKUP_OK=1
fi
fi

Expand All @@ -468,7 +468,7 @@ darRestoreTest () {
log_verbose "yes, the restored file is found"
else
log_error "no, the file is not found"
EVERYTHING_OK=1
BACKUP_OK=1
fi

if [[ $VERBOSE == "y" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion bin/par2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ RESULT=0
while IFS= read -r -d "" file
do
echo "Generate 5% repair data for: \"$file\""
par2 c -r5 -n1 "$file"
par2 c -r5 -n1 "$file" > /dev/null 2>&1
if [[ $? != "0" ]]; then
RESULT=1
fi
Expand Down

0 comments on commit 4b16afa

Please sign in to comment.