Add syslog logging option for sequence ebackup

This commit is contained in:
2021-02-04 17:56:12 +01:00
parent 213180013a
commit a4e453ee22
2 changed files with 18 additions and 0 deletions

View File

@@ -34,6 +34,11 @@ EBU_SOURCE=
# log file name will be "encBackup_profilename.log" # log file name will be "encBackup_profilename.log"
#EBU_LOG_DIR='/var/log' #EBU_LOG_DIR='/var/log'
# Uncomment to log a message to syslog after
# * backup run
# * cron file update
#EBU_SYSLOG=true
# #
## Age options ## Age options

View File

@@ -5,6 +5,7 @@ toolBin=
toolPpa="ppa:duplicity-team/duplicity-release-git" toolPpa="ppa:duplicity-team/duplicity-release-git"
toolCronDir="/etc/cron.d" toolCronDir="/etc/cron.d"
toolPrefix="encBackup_" toolPrefix="encBackup_"
toolSyslogTag=
# Get script working directory # Get script working directory
# (when called from a different directory) # (when called from a different directory)
@@ -21,6 +22,7 @@ step_config() {
else else
exit 1 exit 1
fi fi
toolSyslogTag="${SCRIPT_NAME}-$SEQ_PROFILE_NAME"
} }
step_1_info() { step_1_info() {
@@ -39,6 +41,7 @@ step_1() {
shift shift
local arg local arg
local retVal
local dupArgs local dupArgs
local purgeAfter=1 local purgeAfter=1
@@ -75,8 +78,11 @@ step_1() {
checkInstalled checkInstalled
setPassphrase setPassphrase
exe $toolBin "${dupArgs[@]}" "$EBU_SOURCE" "$EBU_TARGET" exe $toolBin "${dupArgs[@]}" "$EBU_SOURCE" "$EBU_TARGET"
retVal=$?
unsetPassphrase unsetPassphrase
syslogEntry "Backup complete [$retVal]"
if [ $purgeAfter -ne 0 ] ; then if [ $purgeAfter -ne 0 ] ; then
step purge step purge
fi fi
@@ -242,6 +248,7 @@ step_70() {
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
echo " [I] Update cron for profile $SEQ_PROFILE_NAME" echo " [I] Update cron for profile $SEQ_PROFILE_NAME"
exep "sudo echo \"$cronEntry\" > \"$cronScript\"" exep "sudo echo \"$cronEntry\" > \"$cronScript\""
syslogEntry "Cron file update complete [$EBU_CRONTIME]"
else else
echo " [I] Cron for profile $SEQ_PROFILE_NAME is up to date" echo " [I] Cron for profile $SEQ_PROFILE_NAME is up to date"
fi fi
@@ -298,6 +305,12 @@ checkFileHead() {
return 1 return 1
} }
syslogEntry() {
if [ "$EBU_SYSLOG" == "true" ] ; then
exe logger -t $toolSyslogTag "$@"
fi
}
checkInstalled() { checkInstalled() {
if [ -z "$toolBin" ] ; then if [ -z "$toolBin" ] ; then
command -v $toolName >>/dev/null command -v $toolName >>/dev/null