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"
#EBU_LOG_DIR='/var/log'
# Uncomment to log a message to syslog after
# * backup run
# * cron file update
#EBU_SYSLOG=true
#
## Age options

View File

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