From 27cd9da02c34567c206acd0583d71f365fd0c793 Mon Sep 17 00:00:00 2001 From: ccztux Date: Tue, 19 Mar 2019 10:22:49 +0100 Subject: [PATCH 1/8] Added: .gitignore Updated: README.md which removed from required binaries. --- .gitignore | 1 + README.md | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3106220 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +unversioned diff --git a/README.md b/README.md index f19ab22..ac84553 100644 --- a/README.md +++ b/README.md @@ -239,7 +239,7 @@ backup_encryption_password="test1234" # enable pre backup script functionality (possible values: 1|0) pre_backup_script_enabled="0" -# path to pre backup script +# path to pre backup script pre_backup_script="/home/pi/pre.sh" # exit glsysbackup in case execution of pre backup script was not successful @@ -254,7 +254,7 @@ pre_backup_exit_when_unsuccessful="1" # enable post backup script functionality (possible values: 1|0) post_backup_script_enabled="0" -# path to post backup script +# path to post backup script post_backup_script="/home/pi/post.sh" # exit glsysbackup in case execution of post backup script was not successful @@ -265,7 +265,7 @@ post_backup_exit_when_unsuccessful="1" ## Example job output (initial run with default config): ``` -15:15:57 [pi@localhost]:~$ sudo ./glsysbackup +15:15:57 [pi@localhost]:~$ sudo ./glsysbackup [2018-01-06 15:15:57] glsysbackup: [10111] glsysbackup 2.0.0 starting... (PID=10111) [2018-01-06 15:15:57] glsysbackup: [10111] We are using config file: '/usr/local/glsysbackup/etc/glsysbackup.conf'. [2018-01-06 15:15:57] glsysbackup: [10111] Check if root priviliges are required... @@ -456,7 +456,6 @@ post_backup_exit_when_unsuccessful="1" ## It requires the following binaries: - **bash** (Version 3 || 4) -- **which** to get the full path to the required binaries through environment variable $PATH - **pgrep** to check if an instance of glsysbackup is already running - **whoami** to check the user who executes glsysbackup - **date** for logging purposes (Only required if bash version < 4.2. Else printf bash builtin will be used.) From d0ae62b07baf6c0af98f07054cafaed638728fda Mon Sep 17 00:00:00 2001 From: ccztux Date: Tue, 19 Mar 2019 11:21:11 +0100 Subject: [PATCH 2/8] Implemented: Defuse checkAlreadyRunningInstances (#51) --- usr/local/glsysbackup/bin/glsysbackup | 47 ++++++++------------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/usr/local/glsysbackup/bin/glsysbackup b/usr/local/glsysbackup/bin/glsysbackup index c78df5f..bb08416 100755 --- a/usr/local/glsysbackup/bin/glsysbackup +++ b/usr/local/glsysbackup/bin/glsysbackup @@ -111,7 +111,7 @@ printScriptInfos() printf "Copyright:\\t\\t%s\\n" "${script_copyright}" } -checkOption() +checkBashOption() { local option="${1}" @@ -129,7 +129,7 @@ checkOption() fi } -setOption() +setBashOption() { local option="${1}" @@ -601,9 +601,9 @@ removeLock() fi } -overrideLock() +removeLeftoverLock() { - logHandler "Overriding lock, because you want it..." + logHandler "Removing leftover lock..." removeLock setLock @@ -888,43 +888,28 @@ checkAlreadyRunningInstance() if [ "${rc}" -ne "0" ] && [ -z "${running_script_pids:-}" ] then - logHandler "No other instance of: '${script_name}' is currently running (Lockfile: '${script_lock_file}' doesnt exist and no processes are running)." + logHandler "No other instance of: '${script_name}' is currently running (Neither lockfile: '${script_lock_file}' nor running processes detected)." setLock elif [ "${rc}" -eq "0" ] && [ -z "${running_script_pids:-}" ] then - logHandler "Another instance of: '${script_name}' seems to be running (Lockfile: '${script_lock_file}' exists and no processes are running). Maybe ${script_name} was terminated abnormally." - - if [ "${script_override_lock}" -eq "1" ] - then - overrideLock - else - logHandler "HINT: You can override the old left over lock by calling ${script_name} with option '-o'." - - script_another_instance_is_running="1" - script_bypass_exit_routines="1" - script_exit_code="90" - exit - fi + logHandler "Old, leftover lockfile: '${script_lock_file}', but no running processes detected. Maybe ${script_name} was terminated abnormally." + removeLeftoverLock elif [ "${rc}" -eq "0" ] && [ -n "${running_script_pids:-}" ] then running_script_pids="${running_script_pids:0:$((${#running_script_pids} - 2))}" - logHandler "Another instance of: '${script_name}' is currently running (Lockfile: '${script_lock_file}' exists and the following processes: '${running_script_pids}' are running)." + logHandler "Another instance of: '${script_name}' is currently running (Lockfile: '${script_lock_file}' and the following, running processes: '${running_script_pids}' detected)." script_another_instance_is_running="1" script_bypass_exit_routines="1" - script_exit_code="91" + script_exit_code="90" exit elif [ "${rc}" -ne "0" ] && [ -n "${running_script_pids:-}" ] then running_script_pids="${running_script_pids:0:$((${#running_script_pids} - 2))}" - logHandler "Another instance of: '${script_name}' is currently running (Lockfile: '${script_lock_file}' doesnt exist and the following processes: '${running_script_pids}' are running)." - - script_another_instance_is_running="1" - script_bypass_exit_routines="1" - script_exit_code="92" - exit + logHandler "No other instance of: '${script_name}' is currently running (Lockfile: '${script_lock_file}' doesnt exist, but the following, running processes: '${running_script_pids}' detected)." + setLock fi } @@ -1818,9 +1803,9 @@ main() setCommonVars includeConfig checkConfig - if ! checkOption "extglob" + if ! checkBashOption "extglob" then - setOption "extglob" + setBashOption "extglob" fi checkRootPrivileges getUser @@ -1846,8 +1831,7 @@ main() OPTERR="0" -# shellcheck disable=SC2213 -while getopts ":h.c:o.v." OPTION +while getopts ":h.c:v" OPTION do case "${OPTION}" in h) @@ -1859,9 +1843,6 @@ do c) script_config_file="${OPTARG}" ;; - o) - script_override_lock="1" - ;; v) printScriptInfos script_bypass_exit_routines="1" From 3b4b24fac138419b4999545cd8109d302bdb6143 Mon Sep 17 00:00:00 2001 From: ccztux Date: Tue, 19 Mar 2019 11:35:12 +0100 Subject: [PATCH 3/8] Fixed: Globbing doesnt work as expected (#66) Fixed: SC2034, SC2213 --- usr/local/glsysbackup/bin/glsysbackup | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/usr/local/glsysbackup/bin/glsysbackup b/usr/local/glsysbackup/bin/glsysbackup index bb08416..b7f61f9 100755 --- a/usr/local/glsysbackup/bin/glsysbackup +++ b/usr/local/glsysbackup/bin/glsysbackup @@ -76,7 +76,6 @@ script_exit_code="255" script_another_instance_is_running="0" script_bypass_exit_routines="0" script_shutdown_in_progress="0" -script_override_lock="0" @@ -783,7 +782,15 @@ setCommonVars() fi } -checkOpts() +setRequiredBashOptions() +{ + if ! checkBashOption "nullglob" + then + setBashOption "nullglob" + fi +} + +checkCliOptions() { if [ -n "${script_config_file:-}" ] then @@ -1798,15 +1805,12 @@ executePostBackupScript() main() { - checkOpts + checkCliOptions setDefaultConfig setCommonVars + setRequiredBashOptions includeConfig checkConfig - if ! checkBashOption "extglob" - then - setBashOption "extglob" - fi checkRootPrivileges getUser checkBashVersion @@ -1831,18 +1835,18 @@ main() OPTERR="0" -while getopts ":h.c:v" OPTION +while getopts ":c:hv" OPTION do case "${OPTION}" in + c) + script_config_file="${OPTARG}" + ;; h) printUsage script_bypass_exit_routines="1" script_exit_code="230" exit ;; - c) - script_config_file="${OPTARG}" - ;; v) printScriptInfos script_bypass_exit_routines="1" From 60c0eb54c3a3e92cd812a75cc3cc730784d03369 Mon Sep 17 00:00:00 2001 From: ccztux Date: Tue, 19 Mar 2019 11:41:42 +0100 Subject: [PATCH 4/8] Implemented: Remove unimplemented function: checkConfig (#68) --- usr/local/glsysbackup/bin/glsysbackup | 7 ------- 1 file changed, 7 deletions(-) diff --git a/usr/local/glsysbackup/bin/glsysbackup b/usr/local/glsysbackup/bin/glsysbackup index b7f61f9..446afe6 100755 --- a/usr/local/glsysbackup/bin/glsysbackup +++ b/usr/local/glsysbackup/bin/glsysbackup @@ -295,12 +295,6 @@ includeConfig() fi } -checkConfig() -{ - # todo - return -} - logHandlerSetConfig() { log_conf= @@ -1810,7 +1804,6 @@ main() setCommonVars setRequiredBashOptions includeConfig - checkConfig checkRootPrivileges getUser checkBashVersion From 241d190238b63593b0c84a81fd8836d0663ea6bb Mon Sep 17 00:00:00 2001 From: ccztux Date: Tue, 19 Mar 2019 14:15:29 +0100 Subject: [PATCH 5/8] Fixed: Wrong order when rotating and cleaning up backup files. (#70) --- usr/local/glsysbackup/bin/glsysbackup | 139 +++++++++------------ usr/local/glsysbackup/etc/glsysbackup.conf | 2 +- 2 files changed, 57 insertions(+), 84 deletions(-) diff --git a/usr/local/glsysbackup/bin/glsysbackup b/usr/local/glsysbackup/bin/glsysbackup index 446afe6..2ff3fa2 100755 --- a/usr/local/glsysbackup/bin/glsysbackup +++ b/usr/local/glsysbackup/bin/glsysbackup @@ -11,7 +11,7 @@ # Project website: https://github.com/ccztux/glsysbackup # # Last Modification: Christian Zettel (ccztux) -# 2019-03-16 +# 2019-03-19 # # Description: Generic Linux System Backup is an advanced backup tool written in bash. # @@ -69,7 +69,7 @@ script_version="2.0.0-beta.1" script_author="Christian Zettel (ccztux)" script_copyright="Copyright © 2017 ${script_author}, all rights reserved" script_project_website="https://github.com/ccztux/glsysbackup" -script_last_modification_date="2019-03-16" +script_last_modification_date="2019-03-19" script_license="GNU GPLv3" script_description="${script_name} (Generic Linux System Backup) is an advanced backup tool written in bash." script_exit_code="255" @@ -606,71 +606,96 @@ cleanUp() { logHandler "Now we are doing some cleanup jobs..." - removeUnencryptedBackupFile removeInstalledPackagesFile removeOldLeftoverLatestBackups } -removeUnencryptedBackupFile() +removeInstalledPackagesFile() { - if [ "${backup_encryption_enabled:-}" -eq "1" ] + if [ "${installed_packages_enabled:-}" -eq "1" ] then - logHandler "Backup encryption is enabled, now we check if unencrypted backup file exists, if it is writeable and delete it..." - logHandler "Check if unencrypted backup file: '${backup_filename}' exists and if it is writeable..." + logHandler "Installed packages functionality is enabled, now we check if the file exists, if it is writeable and delete it..." + logHandler "Check if installed packages file: '${installed_packages_filename}' exists and if it is writeable..." - checkFileParameters "${backup_filename}" + checkFileParameters "${installed_packages_filename}" if [ "$((file_permission & b_regular_file_exists))" -gt "0" ] && [ "$((file_permission & b_permission_write))" -gt "0" ] then - logHandler "Unencrypted backup file exists and it is writeable." - logHandler "Deleting unencrypted backup file..." + logHandler "Installed packages file exists and is writeable." + logHandler "Deleting installed packages file..." # shellcheck disable=SC2154 - if ${rm_bin} "${backup_filename}" 2>&1 | logHandler + if ${rm_bin} "${installed_packages_filename}" 2>&1 | logHandler then - logHandler "Deleting unencrypted backup file was successful." + logHandler "Deleting installed packages file was successful." else - logHandler "Deleting unencrypted backup file was not successful." - script_exit_code="40" + logHandler "Deleting installed packages file was not successful." + script_exit_code="50" fi elif [ "$((file_permission & b_regular_file_exists))" -eq "0" ] then - logHandler "Unencrypted backup file doesnt exist, nothing to do." + logHandler "Installed packages file doesnt exist, nothing to do." else - logHandler "Unencrypted backup file is not writeable, we can not delete it." - script_exit_code="41" + logHandler "Installed packages file exists, but it is not writeable, we can not delete it." + script_exit_code="51" fi fi } -removeInstalledPackagesFile() +removeOldLeftoverLatestBackups() { - if [ "${installed_packages_enabled:-}" -eq "1" ] + logHandler "Checking for old, leftover backups in latest folder..." + + if [ "${backup_encryption_enabled}" -eq "0" ] then - logHandler "Installed packages functionality is enabled, now we check if the file exists, if it is writeable and delete it..." - logHandler "Check if installed packages file: '${installed_packages_filename}' exists and if it is writeable..." + logHandler "Backup encryption is not enabled, now we check if an lefover encrypted backup file exists, if it is writeable and delete it..." + logHandler "Check if encrypted backup file: '${backup_encryption_filename}' exists and if it is writeable..." - checkFileParameters "${installed_packages_filename}" + checkFileParameters "${backup_encryption_filename}" if [ "$((file_permission & b_regular_file_exists))" -gt "0" ] && [ "$((file_permission & b_permission_write))" -gt "0" ] then - logHandler "Installed packages file exists and is writeable." - logHandler "Deleting installed packages file..." + logHandler "Old, leftover encrypted backup found in latest folder: '${backup_encryption_filename}' and we have write permission, so we delete it." # shellcheck disable=SC2154 - if ${rm_bin} "${installed_packages_filename}" 2>&1 | logHandler + if ${rm_bin} "${backup_encryption_filename}" 2>&1 | logHandler then - logHandler "Deleting installed packages file was successful." + logHandler "Deleting file was successful." else - logHandler "Deleting installed packages file was not successful." - script_exit_code="50" + logHandler "Deleting file was not successful." + script_exit_code="210" + exit fi elif [ "$((file_permission & b_regular_file_exists))" -eq "0" ] then - logHandler "Installed packages file doesnt exist, nothing to do." + logHandler "No old, leftover encrypted backup found in latest folder." else - logHandler "Installed packages file exists, but it is not writeable, we can not delete it." - script_exit_code="51" + logHandler "Old, leftover encrypted backup found in latest folder: '${backup_encryption_filename}', but we dont have write permissions, nothing to do." + fi + else + logHandler "Backup encryption is enabled, now we check if an lefover unencrypted backup file exists, if it is writeable and delete it..." + logHandler "Check if unencrypted backup file: '${backup_filename}' exists and if it is writeable..." + + checkFileParameters "${backup_filename}" + + if [ "$((file_permission & b_regular_file_exists))" -gt "0" ] && [ "$((file_permission & b_permission_write))" -gt "0" ] + then + logHandler "Old, leftover unencrypted backup found in latest folder: '${backup_filename}' and we have write permission, so we delete it." + + # shellcheck disable=SC2154 + if ${rm_bin} "${backup_filename}" 2>&1 | logHandler + then + logHandler "Deleting file was successful." + else + logHandler "Deleting file was not successful." + script_exit_code="211" + exit + fi + elif [ "$((file_permission & b_regular_file_exists))" -eq "0" ] + then + logHandler "No old, leftover unencrypted backup found in latest folder." + else + logHandler "Old, leftover unencrypted backup found in latest folder: '${backup_filename}', but we dont have write permissions, nothing to do." fi fi } @@ -1697,58 +1722,6 @@ encryptBackup() fi } -removeOldLeftoverLatestBackups() -{ - logHandler "Checking for old, leftover backups in latest folder..." - - if [ "${backup_encryption_enabled}" -eq "1" ] - then - checkFileParameters "${backup_encryption_filename}" - - if [ "$((file_permission & b_regular_file_exists))" -gt "0" ] && [ "$((file_permission & b_permission_write))" -gt "0" ] - then - logHandler "Old, leftover encrypted backup found in latest folder: '${backup_encryption_filename}' and we have write permission, so we delete it." - - # shellcheck disable=SC2154 - if ${rm_bin} "${backup_encryption_filename}" 2>&1 | logHandler - then - logHandler "Deleting file was successful." - else - logHandler "Deleting file was not successful." - script_exit_code="210" - exit - fi - elif [ "$((file_permission & b_regular_file_exists))" -eq "0" ] - then - logHandler "No old, leftover encrypted backup found in latest folder." - else - logHandler "Old, leftover encrypted backup found in latest folder: '${backup_encryption_filename}', but we dont have write permissions, nothing to do." - fi - else - checkFileParameters "${backup_filename}" - - if [ "$((file_permission & b_regular_file_exists))" -gt "0" ] && [ "$((file_permission & b_permission_write))" -gt "0" ] - then - logHandler "Old, leftover unencrypted backup found in latest folder: '${backup_filename}' and we have write permission, so we delete it." - - # shellcheck disable=SC2154 - if ${rm_bin} "${backup_filename}" 2>&1 | logHandler - then - logHandler "Deleting file was successful." - else - logHandler "Deleting file was not successful." - script_exit_code="211" - exit - fi - elif [ "$((file_permission & b_regular_file_exists))" -eq "0" ] - then - logHandler "No old, leftover unencrypted backup found in latest folder." - else - logHandler "Old, leftover unencrypted backup found in latest folder: '${backup_filename}', but we dont have write permissions, nothing to do." - fi - fi -} - executePostBackupScript() { local rc= diff --git a/usr/local/glsysbackup/etc/glsysbackup.conf b/usr/local/glsysbackup/etc/glsysbackup.conf index e8934f7..b590912 100755 --- a/usr/local/glsysbackup/etc/glsysbackup.conf +++ b/usr/local/glsysbackup/etc/glsysbackup.conf @@ -11,7 +11,7 @@ # Project website: https://github.com/ccztux/glsysbackup # # Last Modification: Christian Zettel (ccztux) -# 2018-03-16 +# 2018-03-19 # # Description: Generic Linux System Backup is an advanced backup tool written in bash. # From dc049039303a7ed301cdd009bb2938582586a340 Mon Sep 17 00:00:00 2001 From: ccztux Date: Tue, 19 Mar 2019 14:55:46 +0100 Subject: [PATCH 6/8] Implemented: Add logrotate config file and add option to log only the last backup cycle. (#72) Changed: Variable: bash_lineno in function sigHandler renamed to: lineno Improvements in functions: checkAlreadyRunningInstance and rotateHandler --- etc/logrotate.d/glsysbackup | 9 +++ usr/local/glsysbackup/bin/glsysbackup | 69 ++++++++++++++-------- usr/local/glsysbackup/etc/glsysbackup.conf | 3 + 3 files changed, 55 insertions(+), 26 deletions(-) create mode 100755 etc/logrotate.d/glsysbackup diff --git a/etc/logrotate.d/glsysbackup b/etc/logrotate.d/glsysbackup new file mode 100755 index 0000000..2d0070a --- /dev/null +++ b/etc/logrotate.d/glsysbackup @@ -0,0 +1,9 @@ +/usr/local/glsysbackup/var/log/*.log +{ + weekly + rotate 6 + missingok + notifempty + sharedscripts + compress +} diff --git a/usr/local/glsysbackup/bin/glsysbackup b/usr/local/glsysbackup/bin/glsysbackup index 2ff3fa2..1822efa 100755 --- a/usr/local/glsysbackup/bin/glsysbackup +++ b/usr/local/glsysbackup/bin/glsysbackup @@ -76,6 +76,7 @@ script_exit_code="255" script_another_instance_is_running="0" script_bypass_exit_routines="0" script_shutdown_in_progress="0" +script_log_file_truncated="0" @@ -303,6 +304,7 @@ logHandlerSetConfig() b_log_to_syslog="4" b_date_bin_available="8" b_logger_bin_available="16" + b_log_to_file_truncate="32" if [ "${date_bin_printf:-}" -eq "1" ] then @@ -337,6 +339,11 @@ logHandlerSetConfig() then log_conf="$((log_conf | b_logger_bin_available))" fi + + if [ "${log_to_file_truncate}" -eq "1" ] + then + log_conf="$((log_conf | b_log_to_file_truncate))" + fi } logHandlerStdinHelper() @@ -378,6 +385,14 @@ logHandler() if [ "$((log_conf & b_log_to_file))" -gt "0" ] then + if [ "$((log_conf & b_log_to_file_truncate))" -gt "0" ] && [ "${script_log_file_truncated}" -ne "1" ] + then + if >|"${script_log_file}" + then + script_log_file_truncated="1" + fi + fi + if [ "$((log_conf & b_date_bin_available))" -gt "0" ] then if [ -z "${log_timestamp}" ] @@ -405,7 +420,7 @@ sigHandler() { local signal="${1:-}" local bash_source="${2:-}" - local bash_lineno="${3:-}" + local lineno="${3:-}" local bash_command="${4:-}" case "${signal}" in @@ -457,7 +472,7 @@ sigHandler() ERR) if [ "${script_shutdown_in_progress}" -ne "1" ] then - logHandler "Caught: '${signal}', in: '${bash_source}' at line number: '${bash_lineno}', command: '${bash_command}'." + logHandler "Caught: '${signal}', in: '${bash_source}' at line number: '${lineno}', command: '${bash_command}'." fi script_exit_code="1" @@ -749,6 +764,7 @@ setDefaultConfig() log_to_stdout="1" log_to_syslog="0" log_timestamp_format="%Y-%m-%d %H:%M:%S" + log_to_file_truncate="1" root_privileges_required="1" re_nice_enabled="0" re_nice_priority="19" @@ -896,7 +912,6 @@ checkBashVersion() checkAlreadyRunningInstance() { - local rc= local running_script_pids= # shellcheck disable=SC2154 @@ -909,33 +924,33 @@ checkAlreadyRunningInstance() logHandler "Check if another instance of: '${script_name}' is already running..." - checkLock - rc="${?}" - - if [ "${rc}" -ne "0" ] && [ -z "${running_script_pids:-}" ] - then - logHandler "No other instance of: '${script_name}' is currently running (Neither lockfile: '${script_lock_file}' nor running processes detected)." - setLock - elif [ "${rc}" -eq "0" ] && [ -z "${running_script_pids:-}" ] - then - logHandler "Old, leftover lockfile: '${script_lock_file}', but no running processes detected. Maybe ${script_name} was terminated abnormally." - removeLeftoverLock - elif [ "${rc}" -eq "0" ] && [ -n "${running_script_pids:-}" ] + if checkLock then - running_script_pids="${running_script_pids:0:$((${#running_script_pids} - 2))}" + if [ -z "${running_script_pids:-}" ] + then + logHandler "Old, leftover lockfile: '${script_lock_file}', but no running processes detected. Maybe ${script_name} was terminated abnormally." + removeLeftoverLock + else + running_script_pids="${running_script_pids:0:$((${#running_script_pids} - 2))}" - logHandler "Another instance of: '${script_name}' is currently running (Lockfile: '${script_lock_file}' and the following, running processes: '${running_script_pids}' detected)." + logHandler "Another instance of: '${script_name}' is currently running (Lockfile: '${script_lock_file}' and the following, running processes: '${running_script_pids}' detected)." - script_another_instance_is_running="1" - script_bypass_exit_routines="1" - script_exit_code="90" - exit - elif [ "${rc}" -ne "0" ] && [ -n "${running_script_pids:-}" ] - then - running_script_pids="${running_script_pids:0:$((${#running_script_pids} - 2))}" + script_another_instance_is_running="1" + script_bypass_exit_routines="1" + script_exit_code="90" + exit + fi + else + if [ -z "${running_script_pids:-}" ] + then + logHandler "No other instance of: '${script_name}' is currently running (Neither lockfile: '${script_lock_file}' nor running processes detected)." + setLock + else + running_script_pids="${running_script_pids:0:$((${#running_script_pids} - 2))}" - logHandler "No other instance of: '${script_name}' is currently running (Lockfile: '${script_lock_file}' doesnt exist, but the following, running processes: '${running_script_pids}' detected)." - setLock + logHandler "No other instance of: '${script_name}' is currently running (Lockfile: '${script_lock_file}' doesnt exist, but the following, running processes: '${running_script_pids}' detected)." + setLock + fi fi } @@ -1452,6 +1467,7 @@ rotateHandler() fi else logHandler "Today is not the day, where we should rotate the ${rotation_type} backups (actual_weekday: '${actual_weekday}' != backup_rotation_weekly_weekday: '${backup_rotation_weekly_weekday}')." + continue fi fi ;; @@ -1496,6 +1512,7 @@ rotateHandler() fi else logHandler "Today is not the day, where we should rotate the ${rotation_type} backups (actual_day_of_month: '${actual_day_of_month}' != backup_rotation_monthly_day_of_month: '${backup_rotation_monthly_day_of_month}')." + continue fi fi ;; diff --git a/usr/local/glsysbackup/etc/glsysbackup.conf b/usr/local/glsysbackup/etc/glsysbackup.conf index b590912..427b6dc 100755 --- a/usr/local/glsysbackup/etc/glsysbackup.conf +++ b/usr/local/glsysbackup/etc/glsysbackup.conf @@ -59,6 +59,9 @@ log_to_syslog="0" # timestamp format for log messages. log_timestamp_format="%Y-%m-%d %H:%M:%S" +# truncate logfile at each backup cycle (possible values: 1|0) +log_to_file_truncate="0" + #------------ From 233d1e972d2272e67cd5ac956712cb3ca8fff53c Mon Sep 17 00:00:00 2001 From: ccztux Date: Tue, 19 Mar 2019 15:19:28 +0100 Subject: [PATCH 7/8] Implemented: Update README.md. (#58) --- README.md | 278 +++++++++------------ VERSION | 2 +- usr/local/glsysbackup/bin/glsysbackup | 9 +- usr/local/glsysbackup/etc/glsysbackup.conf | 2 + 4 files changed, 133 insertions(+), 158 deletions(-) diff --git a/README.md b/README.md index ac84553..bf376ae 100644 --- a/README.md +++ b/README.md @@ -54,19 +54,18 @@ Start glsysbackup: ## Example help output: ``` -14:18:24 [pi@localhost]:~$ sudo ./glsysbackup -h +15:11:58 [pi@wurlitzer]:~$ sudo /usr/local/glsysbackup/bin/glsysbackup -h Usage: glsysbackup OPTIONS -Author: Christian Zettel (ccztux) -Last modification: 2018-12-02 -Version: 2.0.0 +Author: Christian Zettel (ccztux) +Last modification: 2019-03-19 +Version: 2.0.0-beta3 Description: glsysbackup (Generic Linux System Backup) is an advanced backup tool written in bash. OPTIONS: + -c Path to config file. Example: '/usr/local/glsysbackup/etc/glsysbackup.conf'. (The file extension has to be: '.conf') -h Shows this help. - -c Path to config file. The file extension has to be: '.conf'. (If undefined, default value: '/usr/local/glsysbackup/etc/glsysbackup.conf' will be used.) - -o Override lock in case glsysbackup was terminated abnormally. -v Shows detailed version information. ``` @@ -81,12 +80,6 @@ OPTIONS: # enable log to file. (possible values: 1|0) log_to_file="1" -# log directory -log_directory="${script_base_path}/var/log/" - -# filename of logfile -log_filename="${script_config_name}.log" - # enable log to stdout (possible values: 1|0) log_to_stdout="1" @@ -96,6 +89,9 @@ log_to_syslog="0" # timestamp format for log messages. log_timestamp_format="%Y-%m-%d %H:%M:%S" +# truncate logfile at each backup cycle (possible values: 1|0) +log_to_file_truncate="0" + #------------ @@ -159,8 +155,8 @@ backup_rotation_weekly_max_backups="8" # enable monthly backup rotation (possible values: 1|0) backup_rotation_monthly_enabled="1" -# rotation weekday for monthly rotation. 1 is monday. (possible values: 1|2|3|4|5|6|7) -backup_rotation_monthly_weekday="1" +# rotation day of month for monthly rotation. 1 is monday. (possible values: 1|2|3|...|last day of month) +backup_rotation_monthly_day_of_month="1" # number of backup files to keep of monthly backups backup_rotation_monthly_max_backups="6" @@ -177,8 +173,8 @@ installed_packages_enabled="1" # force this package manager to create installed packages file, if you have more than one package manager installed (possible values: rpm|dpkg|pacman|equery|pkgutil) installed_packages_forced_manager="" -# file name of installed packages -installed_packages_filename="/root/installed_syspackages.txt" +# path where installed packages file should be created +installed_packages_directory="/root" @@ -198,11 +194,16 @@ backup_verbose_mode_enabled="1" # show backup totals backup_show_totals="1" +# individual tar options +backup_individual_options=( +"" +) + # set backup destination path backup_destination_path="/var/backups" # set backup filename -backup_filename_prefix="my_backup" +backup_base_filename="my_backup" # files and folders you want to backup backup_items=( @@ -216,6 +217,7 @@ backup_items=( # exclude this items from backup (HINT: have a look at: 'man tar') backup_exlude_items=( +"" ) @@ -225,7 +227,7 @@ backup_exlude_items=( #------------ # enable backup encryption with openssl (possible values: 1|0) -backup_encryption_enabled="1" +backup_encryption_enabled="0" # set password for encryption backup_encryption_password="test1234" @@ -265,140 +267,115 @@ post_backup_exit_when_unsuccessful="1" ## Example job output (initial run with default config): ``` -15:15:57 [pi@localhost]:~$ sudo ./glsysbackup -[2018-01-06 15:15:57] glsysbackup: [10111] glsysbackup 2.0.0 starting... (PID=10111) -[2018-01-06 15:15:57] glsysbackup: [10111] We are using config file: '/usr/local/glsysbackup/etc/glsysbackup.conf'. -[2018-01-06 15:15:57] glsysbackup: [10111] Check if root priviliges are required... -[2018-01-06 15:15:57] glsysbackup: [10111] Root privileges are required, checking privileges... -[2018-01-06 15:15:57] glsysbackup: [10111] HOORAY, we have root privileges. :) -[2018-01-06 15:15:57] glsysbackup: [10111] Get user which starts the script... -[2018-01-06 15:15:57] glsysbackup: [10111] glsysbackup was started by user: 'pi'. -[2018-01-06 15:15:57] glsysbackup: [10111] Checking bash version... -[2018-01-06 15:15:57] glsysbackup: [10111] Bash version: '4' meets requirements. -[2018-01-06 15:15:57] glsysbackup: [10111] Check if another instance of: 'glsysbackup' is already running... -[2018-01-06 15:15:57] glsysbackup: [10111] Check if lock file: '/usr/local/glsysbackup/var/lock/glsysbackup.lock' exists and if it is read and writeable... -[2018-01-06 15:15:57] glsysbackup: [10111] Lock file doesnt exist. -[2018-01-06 15:15:57] glsysbackup: [10111] No other instance of: 'glsysbackup' is currently running (Lockfile: '/usr/local/glsysbackup/var/lock/glsysbackup.lock' doesnt exist and no processes are running). -[2018-01-06 15:15:57] glsysbackup: [10111] Check if script lock directory: '/usr/local/glsysbackup/var/lock' exists and permissions to set lock are ok... -[2018-01-06 15:15:57] glsysbackup: [10111] Script lock directory exists and permissions are ok. -[2018-01-06 15:15:57] glsysbackup: [10111] Setting lock... -[2018-01-06 15:15:57] glsysbackup: [10111] Setting lock was successful. -[2018-01-06 15:15:57] glsysbackup: [10111] Check if re-niceing is enabled... -[2018-01-06 15:15:57] glsysbackup: [10111] Re-niceing is not enabled. -[2018-01-06 15:15:57] glsysbackup: [10111] Check if re-ioniceing is enabled... -[2018-01-06 15:15:57] glsysbackup: [10111] Re-ioniceing is not enabled. -[2018-01-06 15:15:57] glsysbackup: [10111] Check backup dir structure... -[2018-01-06 15:15:57] glsysbackup: [10111] Check if backup directory: '/var/backups' exists and permissions to move files are ok... -[2018-01-06 15:15:57] glsysbackup: [10111] Backup directory exists and permissions are ok. -[2018-01-06 15:15:57] glsysbackup: [10111] Directory: '/var/backups/wurlitzer/glsysbackup/daily' doesnt exist. -[2018-01-06 15:15:57] glsysbackup: [10111] Creating directory... -[2018-01-06 15:15:57] glsysbackup: [10111] Creating directory: '/var/backups/wurlitzer/glsysbackup/daily' was successful. -[2018-01-06 15:15:57] glsysbackup: [10111] Directory: '/var/backups/wurlitzer/glsysbackup/weekly' doesnt exist. -[2018-01-06 15:15:57] glsysbackup: [10111] Creating directory... -[2018-01-06 15:15:57] glsysbackup: [10111] Creating directory: '/var/backups/wurlitzer/glsysbackup/weekly' was successful. -[2018-01-06 15:15:57] glsysbackup: [10111] Directory: '/var/backups/wurlitzer/glsysbackup/monthly' doesnt exist. -[2018-01-06 15:15:57] glsysbackup: [10111] Creating directory... -[2018-01-06 15:15:57] glsysbackup: [10111] Creating directory: '/var/backups/wurlitzer/glsysbackup/monthly' was successful. -[2018-01-06 15:15:57] glsysbackup: [10111] Directory: '/var/backups/wurlitzer/glsysbackup/latest' doesnt exist. -[2018-01-06 15:15:57] glsysbackup: [10111] Creating directory... -[2018-01-06 15:15:58] glsysbackup: [10111] Creating directory: '/var/backups/wurlitzer/glsysbackup/latest' was successful. -[2018-01-06 15:15:58] glsysbackup: [10111] Check if pre backup script functionality is enabled... -[2018-01-06 15:15:58] glsysbackup: [10111] Pre backup script functionality is enabled. -[2018-01-06 15:15:58] glsysbackup: [10111] Check if pre backup script (/home/pi/pre.sh) exists and if it is executeable... -[2018-01-06 15:15:58] glsysbackup: [10111] Pre backup script exists and it is executeable, so we execute it... -[2018-01-06 15:15:58] glsysbackup: [10111] Doing something here in pre script.... 1 -[2018-01-06 15:15:58] glsysbackup: [10111] Doing something here in pre script.... 2 -[2018-01-06 15:15:58] glsysbackup: [10111] Doing something here in pre script.... 3 -[2018-01-06 15:15:58] glsysbackup: [10111] Doing something here in pre script.... 4 -[2018-01-06 15:15:58] glsysbackup: [10111] Doing something here in pre script.... 5 -[2018-01-06 15:15:58] glsysbackup: [10111] Execution of pre backup script was successful. rc: '0'. -[2018-01-06 15:15:58] glsysbackup: [10111] Check if installed packages are enabled... -[2018-01-06 15:15:58] glsysbackup: [10111] Installed packages are enabled. -[2018-01-06 15:15:58] glsysbackup: [10111] The supported system package manager we found is: 'dpkg'. -[2018-01-06 15:15:58] glsysbackup: [10111] Creating installed packages file: '/root/installed_syspackages.txt'... -[2018-01-06 15:15:59] glsysbackup: [10111] Creating installed packages file was successful, adding file to backup_items config array. -[2018-01-06 15:15:59] glsysbackup: [10111] Check if we need to build excluding options... -[2018-01-06 15:15:59] glsysbackup: [10111] Building of excluding options is enabled. -[2018-01-06 15:15:59] glsysbackup: [10111] We build the following excluding options: '--exclude='/old.backups' --exclude='/old.mysqldumps/''. -[2018-01-06 15:15:59] glsysbackup: [10111] Building backup options... -[2018-01-06 15:15:59] glsysbackup: [10111] We build the following backup options: '--create --gzip --file=/var/backups/wurlitzer/glsysbackup/latest/my_backup.tar.gz --verbose --totals'. -[2018-01-06 15:15:59] glsysbackup: [10111] Starting backup job... -[2018-01-06 15:15:59] glsysbackup: [10111] /bin/tar: Entferne führende „/“ von Elementnamen -[2018-01-06 15:15:59] glsysbackup: [10111] /etc/ -[2018-01-06 15:15:59] glsysbackup: [10111] /etc/locale.alias -[2018-01-06 15:15:59] glsysbackup: [10111] /etc/subgid -[2018-01-06 15:15:59] glsysbackup: [10111] /etc/sgml/ -[2018-01-06 15:15:59] glsysbackup: [10111] /etc/sgml/xml-core.cat -[2018-01-06 15:15:59] glsysbackup: [10111] /etc/sgml/catalog -[2018-01-06 15:15:59] glsysbackup: [10111] /etc/securetty -[2018-01-06 15:15:59] glsysbackup: [10111] /etc/ppp/ +15:12:00 [pi@wurlitzer]:~$ sudo /usr/local/glsysbackup/bin/glsysbackup -c /usr/local/glsysbackup/etc/glsysbackup.conf +[2019-03-19 15:12:43] glsysbackup: [26411] glsysbackup 2.0.0-beta3 starting... (PID=26411) +[2019-03-19 15:12:43] glsysbackup: [26411] We are using config file: '/usr/local/glsysbackup/etc/glsysbackup.conf'. +[2019-03-19 15:12:43] glsysbackup: [26411] Check if root priviliges are required... +[2019-03-19 15:12:43] glsysbackup: [26411] Root privileges are required, checking privileges... +[2019-03-19 15:12:43] glsysbackup: [26411] HOORAY, we have root privileges. :) +[2019-03-19 15:12:43] glsysbackup: [26411] Get user which starts the script... +[2019-03-19 15:12:43] glsysbackup: [26411] glsysbackup was started by user: 'pi'. +[2019-03-19 15:12:43] glsysbackup: [26411] Checking bash version... +[2019-03-19 15:12:43] glsysbackup: [26411] Bash version: '4' meets requirements. +[2019-03-19 15:12:43] glsysbackup: [26411] Check if another instance of: 'glsysbackup' is already running... +[2019-03-19 15:12:43] glsysbackup: [26411] Check if lock file: '/usr/local/glsysbackup/var/lock/glsysbackup.glsysbackup.lock' exists and if it is read and writeable... +[2019-03-19 15:12:43] glsysbackup: [26411] Lock file doesnt exist. +[2019-03-19 15:12:43] glsysbackup: [26411] No other instance of: 'glsysbackup' is currently running (Neither lockfile: '/usr/local/glsysbackup/var/lock/glsysbackup.glsysbackup.lock' nor running processes detected). +[2019-03-19 15:12:44] glsysbackup: [26411] Check if script lock directory: '/usr/local/glsysbackup/var/lock' exists and permissions to set lock are ok... +[2019-03-19 15:12:44] glsysbackup: [26411] Script lock directory exists and permissions are ok. +[2019-03-19 15:12:44] glsysbackup: [26411] Setting lock... +[2019-03-19 15:12:44] glsysbackup: [26411] Setting lock was successful. +[2019-03-19 15:12:44] glsysbackup: [26411] Check if re-niceing is enabled... +[2019-03-19 15:12:44] glsysbackup: [26411] Re-niceing is not enabled. +[2019-03-19 15:12:44] glsysbackup: [26411] Check if re-ioniceing is enabled... +[2019-03-19 15:12:44] glsysbackup: [26411] Re-ioniceing is not enabled. +[2019-03-19 15:12:44] glsysbackup: [26411] Check backup dir structure... +[2019-03-19 15:12:44] glsysbackup: [26411] Check if backup directory: '/var/backups' exists and permissions to move files are ok... +[2019-03-19 15:12:44] glsysbackup: [26411] Backup directory exists and permissions are ok. +[2019-03-19 15:12:44] glsysbackup: [26411] Directory: '/var/backups/wurlitzer/glsysbackup/daily' exist, nothing to do. +[2019-03-19 15:12:44] glsysbackup: [26411] Directory: '/var/backups/wurlitzer/glsysbackup/weekly' exist, nothing to do. +[2019-03-19 15:12:44] glsysbackup: [26411] Directory: '/var/backups/wurlitzer/glsysbackup/monthly' exist, nothing to do. +[2019-03-19 15:12:44] glsysbackup: [26411] Directory: '/var/backups/wurlitzer/glsysbackup/latest' exist, nothing to do. +[2019-03-19 15:12:44] glsysbackup: [26411] Check if pre backup script functionality is enabled... +[2019-03-19 15:12:44] glsysbackup: [26411] Pre backup script functionality is not enabled. +[2019-03-19 15:12:44] glsysbackup: [26411] Check if installed packages are enabled... +[2019-03-19 15:12:44] glsysbackup: [26411] Installed packages are enabled. +[2019-03-19 15:12:44] glsysbackup: [26411] The supported system package manager we found is: 'dpkg'. +[2019-03-19 15:12:44] glsysbackup: [26411] Creating installed packages file: '/root/glsysbackup.glsysbackup.installed_packges.txt'... +[2019-03-19 15:12:44] glsysbackup: [26411] Creating installed packages file was successful, adding file to backup_items config array. +[2019-03-19 15:12:44] glsysbackup: [26411] Check if we need to build excluding options... +[2019-03-19 15:12:44] glsysbackup: [26411] We dont have to build excluding options... +[2019-03-19 15:12:44] glsysbackup: [26411] Building backup command... +[2019-03-19 15:12:44] glsysbackup: [26411] We build the following backup command: '/bin/tar --create --gzip --file=/var/backups/wurlitzer/glsysbackup/latest/my_backup.tar.gz --verbose --totals /etc/ /home/ /root/ /var/lib/mpd/ /usr/local/bin/ /boot/config.txt /root/glsysbackup.glsysbackup.installed_packges.txt'. +[2019-03-19 15:12:44] glsysbackup: [26411] Starting backup job... +[2019-03-19 15:12:44] glsysbackup: [26411] /bin/tar: Entferne führende „/“ von Elementnamen +[2019-03-19 15:12:44] glsysbackup: [26411] /etc/ +[2019-03-19 15:12:44] glsysbackup: [26411] /etc/locale.alias +[2019-03-19 15:12:44] glsysbackup: [26411] /etc/usb_modeswitch.conf +[2019-03-19 15:12:44] glsysbackup: [26411] /etc/shadow +[2019-03-19 15:12:44] glsysbackup: [26411] /etc/timidity/ +[2019-03-19 15:12:44] glsysbackup: [26411] /etc/timidity/freepats.cfg . . -[snip] +[snip . . -[2018-01-06 15:16:44] glsysbackup: [10111] /usr/local/bin/mpc_playlist_update -[2018-01-06 15:16:44] glsysbackup: [10111] /usr/local/bin/youtube-dl -[2018-01-06 15:16:44] glsysbackup: [10111] /usr/local/bin/wurlitzerd -[2018-01-06 15:16:44] glsysbackup: [10111] /usr/local/bin/bashlib -[2018-01-06 15:16:44] glsysbackup: [10111] /usr/local/bin/glsysbackup -[2018-01-06 15:16:44] glsysbackup: [10111] /usr/local/bin/sysupdate -[2018-01-06 15:16:44] glsysbackup: [10111] /boot/config.txt -[2018-01-06 15:16:44] glsysbackup: [10111] /bin/tar: Entferne führende „/“ von Zielen harter Verknüpfungen -[2018-01-06 15:16:44] glsysbackup: [10111] /root/installed_syspackages.txt -[2018-01-06 15:16:44] glsysbackup: [10111] Gesamtzahl geschriebener Bytes: 8980480 (8,6MiB, 456KiB/s) -[2018-01-06 15:16:44] glsysbackup: [10111] Backup job was successful. -[2018-01-06 15:16:44] glsysbackup: [10111] Backup encryption is enabled... -[2018-01-06 15:16:44] glsysbackup: [10111] Encrypting backup file: '/var/backups/wurlitzer/glsysbackup/latest/my_backup.tar.gz'... -[2018-01-06 15:16:45] glsysbackup: [10111] Encrypting job was successful. -[2018-01-06 15:16:45] glsysbackup: [10111] HINT: To decrypt use this command: '/usr/bin/openssl aes-256-cbc -d -salt -in /var/backups/wurlitzer/glsysbackup/latest/my_backup.aes.tar.gz -out /var/backups/wurlitzer/glsysbackup/latest/my_backup.tar.gz'. -[2018-01-06 15:16:45] glsysbackup: [10111] Check if post backup script functionality is enabled... -[2018-01-06 15:16:45] glsysbackup: [10111] Post backup script functionality is enabled. -[2018-01-06 15:16:45] glsysbackup: [10111] Check if post backup script (/home/pi/post.sh) exists and if it is executeable... -[2018-01-06 15:16:45] glsysbackup: [10111] Post backup script exists and it is executeable, so we execute it... -[2018-01-06 15:16:45] glsysbackup: [10111] Doing something here in post script.... 1 -[2018-01-06 15:16:45] glsysbackup: [10111] Doing something here in post script.... 2 -[2018-01-06 15:16:45] glsysbackup: [10111] Doing something here in post script.... 3 -[2018-01-06 15:16:45] glsysbackup: [10111] Doing something here in post script.... 4 -[2018-01-06 15:16:45] glsysbackup: [10111] Doing something here in post script.... 5 -[2018-01-06 15:16:46] glsysbackup: [10111] Execution of post backup script was successful. rc: '0'. -[2018-01-06 15:16:46] glsysbackup: [10111] Caught: 'EXIT', exiting script... -[2018-01-06 15:16:46] glsysbackup: [10111] Now we are doing some cleanup jobs... -[2018-01-06 15:16:46] glsysbackup: [10111] Backup encryption is enabled, now we check if unencrypted backup file exists, if it is writeable and delete it... -[2018-01-06 15:16:46] glsysbackup: [10111] Check if unencrypted backup file: '/var/backups/wurlitzer/glsysbackup/latest/my_backup.tar.gz' exists and if it is writeable... -[2018-01-06 15:16:46] glsysbackup: [10111] Unencrypted backup file exists and it is writeable. -[2018-01-06 15:16:46] glsysbackup: [10111] Deleting unencrypted backup file... -[2018-01-06 15:16:46] glsysbackup: [10111] Deleting unencrypted backup file was successful. -[2018-01-06 15:16:46] glsysbackup: [10111] Installed packages functionality is enabled, now we check if the file exists, if it is writeable and delete it... -[2018-01-06 15:16:46] glsysbackup: [10111] Check if installed packages file: '/root/installed_syspackages.txt' exists and if it is writeable... -[2018-01-06 15:16:46] glsysbackup: [10111] Installed packages file exists and is writeable. -[2018-01-06 15:16:46] glsysbackup: [10111] Deleting installed packages file... -[2018-01-06 15:16:46] glsysbackup: [10111] Deleting installed packages file was successful. -[2018-01-06 15:16:46] glsysbackup: [10111] Check if backup rotation is enabled... -[2018-01-06 15:16:46] glsysbackup: [10111] Backup rotation is enabled. -[2018-01-06 15:16:46] glsysbackup: [10111] Check if only one backup per day is enabled... -[2018-01-06 15:16:46] glsysbackup: [10111] Only one backup per day is enabled. -[2018-01-06 15:16:46] glsysbackup: [10111] Check if old backups of type: 'daily' from today exists... -[2018-01-06 15:16:46] glsysbackup: [10111] No old backups of type: 'daily' from today found. -[2018-01-06 15:16:46] glsysbackup: [10111] Copying actual backup: '/var/backups/wurlitzer/glsysbackup/latest/my_backup.aes.tar.gz' ==> '/var/backups/wurlitzer/glsysbackup/daily/daily_my_backup_2018-01-06_15h16m_Samstag.aes.tar.gz'. -[2018-01-06 15:16:46] glsysbackup: [10111] Copy job was successful. -[2018-01-06 15:16:46] glsysbackup: [10111] Check if rotation of daily backups is necessary... -[2018-01-06 15:16:46] glsysbackup: [10111] Rotation of daily backups is not necessary (backup_files_count: '1' <= backup_rotation_daily_max_backups: '10'). -[2018-01-06 15:16:46] glsysbackup: [10111] Check if today is the day, where weekly backups should be rotated... -[2018-01-06 15:16:46] glsysbackup: [10111] Today is not the day, where we should rotate the weekly backups (actual_weekday: '6' != backup_rotation_weekly_weekday: '1'). -[2018-01-06 15:16:46] glsysbackup: [10111] Check if rotation of weekly backups is necessary... -[2018-01-06 15:16:46] glsysbackup: [10111] Rotation of weekly backups is not necessary (backup_files_count: '1' <= backup_rotation_weekly_max_backups: '8'). -[2018-01-06 15:16:46] glsysbackup: [10111] Check if today is the day, where monthly backups should be rotated... -[2018-01-06 15:16:46] glsysbackup: [10111] Today is not the day, where we should rotate the monthly backups (actual_weekday: '6' != backup_rotation_monthly_weekday: '1'). -[2018-01-06 15:16:46] glsysbackup: [10111] Check if rotation of monthly backups is necessary... -[2018-01-06 15:16:46] glsysbackup: [10111] Rotation of monthly backups is not necessary (backup_files_count: '1' <= backup_rotation_monthly_max_backups: '6'). -[2018-01-06 15:16:46] glsysbackup: [10111] We did a great job. :) -[2018-01-06 15:16:46] glsysbackup: [10111] Check if lock file: '/usr/local/glsysbackup/var/lock/glsysbackup.lock' exists and if it is read and writeable... -[2018-01-06 15:16:46] glsysbackup: [10111] Lock file exists and it is read/writeable. -[2018-01-06 15:16:46] glsysbackup: [10111] Removing lock... -[2018-01-06 15:16:46] glsysbackup: [10111] Removing lock was successful. -[2018-01-06 15:16:47] glsysbackup: [10111] Script was running: '50' seconds, script_exit_code: '0'. -[2018-01-06 15:16:47] glsysbackup: [10111] Bye, bye... +[2019-03-19 15:14:03] glsysbackup: [26411] /usr/local/bin/ +[2019-03-19 15:14:04] glsysbackup: [26411] /usr/local/bin/mpc_playlist_update +[2019-03-19 15:14:04] glsysbackup: [26411] /usr/local/bin/sysupdate +[2019-03-19 15:14:04] glsysbackup: [26411] /usr/local/bin/ctags +[2019-03-19 15:14:04] glsysbackup: [26411] /usr/local/bin/youtube-dl +[2019-03-19 15:14:04] glsysbackup: [26411] /usr/local/bin/proxy_switch +[2019-03-19 15:14:04] glsysbackup: [26411] /usr/local/bin/wurlitzerd +[2019-03-19 15:14:04] glsysbackup: [26411] /usr/local/bin/bashlib +[2019-03-19 15:14:04] glsysbackup: [26411] /boot/config.txt +[2019-03-19 15:14:04] glsysbackup: [26411] /bin/tar: Entferne führende „/“ von Zielen harter Verknüpfungen +[2019-03-19 15:14:04] glsysbackup: [26411] /root/glsysbackup.glsysbackup.installed_packges.txt +[2019-03-19 15:14:04] glsysbackup: [26411] Gesamtzahl geschriebener Bytes: 86108160 (83MiB, 1,2MiB/s) +[2019-03-19 15:14:04] glsysbackup: [26411] Backup job was successful. +[2019-03-19 15:14:04] glsysbackup: [26411] Backup encryption is not enabled... +[2019-03-19 15:14:04] glsysbackup: [26411] Check if post backup script functionality is enabled... +[2019-03-19 15:14:04] glsysbackup: [26411] Post backup script functionality is not enabled. +[2019-03-19 15:14:04] glsysbackup: [26411] Caught: 'EXIT', exiting script... +[2019-03-19 15:14:04] glsysbackup: [26411] Now we are doing some cleanup jobs... +[2019-03-19 15:14:04] glsysbackup: [26411] Installed packages functionality is enabled, now we check if the file exists, if it is writeable and delete it... +[2019-03-19 15:14:04] glsysbackup: [26411] Check if installed packages file: '/root/glsysbackup.glsysbackup.installed_packges.txt' exists and if it is writeable... +[2019-03-19 15:14:04] glsysbackup: [26411] Installed packages file exists and is writeable. +[2019-03-19 15:14:04] glsysbackup: [26411] Deleting installed packages file... +[2019-03-19 15:14:04] glsysbackup: [26411] Deleting installed packages file was successful. +[2019-03-19 15:14:04] glsysbackup: [26411] Checking for old, leftover backups in latest folder... +[2019-03-19 15:14:04] glsysbackup: [26411] Backup encryption is not enabled, now we check if an lefover encrypted backup file exists, if it is writeable and delete it... +[2019-03-19 15:14:04] glsysbackup: [26411] Check if encrypted backup file: '/var/backups/wurlitzer/glsysbackup/latest/my_backup.aes.tar.gz' exists and if it is writeable... +[2019-03-19 15:14:04] glsysbackup: [26411] Old, leftover encrypted backup found in latest folder: '/var/backups/wurlitzer/glsysbackup/latest/my_backup.aes.tar.gz' and we have write permission, so we delete it. +[2019-03-19 15:14:04] glsysbackup: [26411] Deleting file was successful. +[2019-03-19 15:14:04] glsysbackup: [26411] Check if backup rotation is enabled... +[2019-03-19 15:14:04] glsysbackup: [26411] Backup rotation is enabled. +[2019-03-19 15:14:04] glsysbackup: [26411] Check if only one backup per day is enabled... +[2019-03-19 15:14:04] glsysbackup: [26411] Only one backup per day is enabled. +[2019-03-19 15:14:04] glsysbackup: [26411] Check if old backups of type: 'daily' from today exists... +[2019-03-19 15:14:04] glsysbackup: [26411] Backup from today: '/var/backups/wurlitzer/glsysbackup/daily/daily_my_backup_2019-03-19_14h11m_Dienstag.tar.gz' found... +[2019-03-19 15:14:04] glsysbackup: [26411] Check if permissions of file: '/var/backups/wurlitzer/glsysbackup/daily/daily_my_backup_2019-03-19_14h11m_Dienstag.tar.gz' are ok to delete it... +[2019-03-19 15:14:04] glsysbackup: [26411] We have write permissions, so we can delete it. +[2019-03-19 15:14:04] glsysbackup: [26411] Deleting file was successful. +[2019-03-19 15:14:04] glsysbackup: [26411] Backup from today: '/var/backups/wurlitzer/glsysbackup/daily/daily_my_backup_2019-03-19_14h50m_Dienstag.aes.tar.gz' found... +[2019-03-19 15:14:04] glsysbackup: [26411] Check if permissions of file: '/var/backups/wurlitzer/glsysbackup/daily/daily_my_backup_2019-03-19_14h50m_Dienstag.aes.tar.gz' are ok to delete it... +[2019-03-19 15:14:04] glsysbackup: [26411] We have write permissions, so we can delete it. +[2019-03-19 15:14:04] glsysbackup: [26411] Deleting file was successful. +[2019-03-19 15:14:04] glsysbackup: [26411] Copying actual backup: '/var/backups/wurlitzer/glsysbackup/latest/my_backup.tar.gz' ==> '/var/backups/wurlitzer/glsysbackup/daily/daily_my_backup_2019-03-19_15h14m_Dienstag.tar.gz'. +[2019-03-19 15:14:04] glsysbackup: [26411] Copy job was successful. +[2019-03-19 15:14:04] glsysbackup: [26411] Check if rotation of daily backups is necessary... +[2019-03-19 15:14:04] glsysbackup: [26411] Rotation of daily backups is not necessary (backup_files_count: '2' <= backup_rotation_daily_max_backups: '10'). +[2019-03-19 15:14:04] glsysbackup: [26411] Check if today is the day, where weekly backups should be rotated... +[2019-03-19 15:14:04] glsysbackup: [26411] Today is not the day, where we should rotate the weekly backups (actual_weekday: '2' != backup_rotation_weekly_weekday: '1'). +[2019-03-19 15:14:04] glsysbackup: [26411] Check if today is the day, where monthly backups should be rotated... +[2019-03-19 15:14:04] glsysbackup: [26411] Today is not the day, where we should rotate the monthly backups (actual_day_of_month: '19' != backup_rotation_monthly_day_of_month: '1'). +[2019-03-19 15:14:04] glsysbackup: [26411] Check if lock file: '/usr/local/glsysbackup/var/lock/glsysbackup.glsysbackup.lock' exists and if it is read and writeable... +[2019-03-19 15:14:04] glsysbackup: [26411] Lock file exists and it is read/writeable. +[2019-03-19 15:14:04] glsysbackup: [26411] Removing lock... +[2019-03-19 15:14:04] glsysbackup: [26411] Removing lock was successful. +[2019-03-19 15:14:04] glsysbackup: [26411] We did a great job. :) +[2019-03-19 15:14:04] glsysbackup: [26411] Script was running: '81' seconds, script_exit_code: '0'. +[2019-03-19 15:14:04] glsysbackup: [26411] Bye, bye... ``` @@ -473,8 +450,3 @@ post_backup_exit_when_unsuccessful="1" - **openssl** to encrypt the backup file - **renice** to renice glsysbackup and all child processes - **ionice** to re-ionice glsysbackup and all child processes - - - -## Future plans: -- add sendEmail functionality diff --git a/VERSION b/VERSION index 227cea2..5348c7d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.0 +2.0.0-beta3 diff --git a/usr/local/glsysbackup/bin/glsysbackup b/usr/local/glsysbackup/bin/glsysbackup index 1822efa..87246c1 100755 --- a/usr/local/glsysbackup/bin/glsysbackup +++ b/usr/local/glsysbackup/bin/glsysbackup @@ -13,6 +13,8 @@ # Last Modification: Christian Zettel (ccztux) # 2019-03-19 # +# Version 2.0.0-beta3 +# # Description: Generic Linux System Backup is an advanced backup tool written in bash. # # License: GNU GPLv3 @@ -65,7 +67,7 @@ trap 'sigHandler EXIT' EXIT || { printf "Setting essential trap for signal: 'EXI script_pid="${BASHPID}" script_name="${0##*/}" -script_version="2.0.0-beta.1" +script_version="2.0.0-beta3" script_author="Christian Zettel (ccztux)" script_copyright="Copyright © 2017 ${script_author}, all rights reserved" script_project_website="https://github.com/ccztux/glsysbackup" @@ -94,9 +96,8 @@ printUsage() printf "Version:\\t\\t%s\\n\\n" "${script_version}" printf "Description:\\t\\t%s\\n\\n" "${script_description}" printf "OPTIONS:\\n" + printf " -c\\t\\tPath to config file. Example: '%s/etc/%s.conf'. (The file extension has to be: '.conf')\\n" "${script_base_path}" "${script_name}" printf " -h\\t\\tShows this help.\\n" - printf " -c\\t\\tPath to config file. Example: '%s/etc/%s.conf'. (The file extension has to be: '.conf'.)\\n" "${script_base_path}" "${script_name}" - printf " -o\\t\\tOverride lock in case %s was terminated abnormally.\\n" "${script_name}" printf " -v\\t\\tShows detailed version information.\\n" } @@ -839,7 +840,7 @@ checkCliOptions() exit fi else - printf "Mandatory argument: '-c' (Config file) not supplied, exiting.\\n\\n" + printf "Mandatory argument: '-c' (Config file) missing, exiting.\\n\\n" printUsage script_exit_code="61" diff --git a/usr/local/glsysbackup/etc/glsysbackup.conf b/usr/local/glsysbackup/etc/glsysbackup.conf index 427b6dc..79642c1 100755 --- a/usr/local/glsysbackup/etc/glsysbackup.conf +++ b/usr/local/glsysbackup/etc/glsysbackup.conf @@ -13,6 +13,8 @@ # Last Modification: Christian Zettel (ccztux) # 2018-03-19 # +# Version 2.0.0-beta3 +# # Description: Generic Linux System Backup is an advanced backup tool written in bash. # # License: GNU GPLv3 From 4f12fe5b28f61cd653cb2416564b7f497701bb1d Mon Sep 17 00:00:00 2001 From: ccztux Date: Tue, 19 Mar 2019 15:56:26 +0100 Subject: [PATCH 8/8] Fixed: SC2188 Changed: Filename in README.md --- README.md | 4 ++-- usr/local/glsysbackup/bin/glsysbackup | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bf376ae..7099b56 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ Download the latest tarball and extract it: ```bash cd /tmp -wget "https://api.github.com/repos/ccztux/glsysbackup/tarball" -O glsysbackup.master.tar.gz -tar -xvzf glsysbackup.master.tar.gz +wget "https://api.github.com/repos/ccztux/glsysbackup/tarball" -O glsysbackup.latest.tar.gz +tar -xvzf glsysbackup.latest.tar.gz cd ccztux-glsysbackup-* ``` diff --git a/usr/local/glsysbackup/bin/glsysbackup b/usr/local/glsysbackup/bin/glsysbackup index 87246c1..cccbed4 100755 --- a/usr/local/glsysbackup/bin/glsysbackup +++ b/usr/local/glsysbackup/bin/glsysbackup @@ -388,7 +388,7 @@ logHandler() then if [ "$((log_conf & b_log_to_file_truncate))" -gt "0" ] && [ "${script_log_file_truncated}" -ne "1" ] then - if >|"${script_log_file}" + if true >|"${script_log_file}" then script_log_file_truncated="1" fi @@ -765,7 +765,7 @@ setDefaultConfig() log_to_stdout="1" log_to_syslog="0" log_timestamp_format="%Y-%m-%d %H:%M:%S" - log_to_file_truncate="1" + log_to_file_truncate="0" root_privileges_required="1" re_nice_enabled="0" re_nice_priority="19"