From c2dc7a0729bcf8053bbf416f950296ce81136e6f Mon Sep 17 00:00:00 2001 From: ge Date: Tue, 17 May 2022 01:06:02 +0300 Subject: [PATCH] feat: Code improvements --- src/boring-backup | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/boring-backup b/src/boring-backup index f71338e..2840f74 100755 --- a/src/boring-backup +++ b/src/boring-backup @@ -22,14 +22,10 @@ __verbose= __log_file='./log.txt' __log_date_fmt='%d/%b/%Y:%H:%M:%S %z' __tar_options='-acf' -__tar_compression='gzip' +__tar_exclude= __name_date_fmt='_%Y%m%d-%H%M' - -if [ -n "$BBLIB" ]; then - __library="$BBLIB" -else - __library='./lib' -fi +__compression='gzip' +__library="${BBLIB:-./lib}" # Source library for file in "$__library"/*; do @@ -125,21 +121,23 @@ log "Scripts to process (${__count}): ${__args[@]}" for script in "${__args[@]}"; do + # Initialise variables + __user_script="$script" + backups=() # Array of created backups, contains full pathes + errors=() # Array of error messages written by err() function + # Source scripts source_script "$script" + # Config can ovewrite script functions and variables [ -n "$__config" ] && . "$__config" echo - echo -e "\e[1m==> Script: ${__args[__iter-1]##*/} [$__iter/$__count]\e[0m" | log -p - - # Initialise variables - __user_script="$script" - backups=() # Array of created backups, contains full pathes + echo -e "\e[1m--> Script: ${__args[__iter-1]##*/} [$__iter/$__count]\e[0m" | log -p # Run prepare() before all if set if is_function_set prepare; then - log -p "Execute prepare() ..." + echo -e "Execute \e[1mprepare()\e[0m ..." | log -p prepare unset prepare fi @@ -165,8 +163,9 @@ for script in "${__args[@]}"; do ((__iter++)) || true # Unset user defined variables + unset compression unset tar_options - unset tar_compression + unset tar_exclude unset name_date_fmt done