diff --git a/.gitignore b/.gitignore index 5596aec29cb5619fd094878a3c60f79e3b6815ab..01584663a6cb301b8e0d2a72d27abe5c0e3abacb 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,9 @@ keys/* logs/auto-* logs/full-* logs/inc-* +logs/last* +logs/prune* logs/transfer-* -*lastlog \ No newline at end of file +logs/transfer.running +*lastlog +static/* \ No newline at end of file diff --git a/backup.sh b/backup.sh index 121aef6c0eb85d92b14d7cb55adb314e1f7160a0..3142cc319acdada74320b309f9bb469aba791756 100755 --- a/backup.sh +++ b/backup.sh @@ -14,6 +14,7 @@ # # 2022-01-14 ah v1.0 # 2022-02-10 ah v1.1 handle local dumps only; improve infos +# 2022-11-04 ah v1.2 rename hooks # ================================================================================ . $( dirname "$0" )/jobhelper.sh @@ -176,7 +177,7 @@ EOFbackupinfo if [ $bStart -eq 1 ]; then - _j_runHooks "10-before-backup" + _j_runHooks "100-before-backup" sleep 3 diff --git a/docs/50_Hooks/_index.md b/docs/50_Hooks/_index.md index 4ac8c92208a2666ed4fd52cc30cc468d6f18d760..7f7d5ce75e7ef5a147ad59733439a471dc6961f3 100644 --- a/docs/50_Hooks/_index.md +++ b/docs/50_Hooks/_index.md @@ -11,21 +11,21 @@ We have hooks "before" a step starts and "afterwards". In the IML Backup exist the following hooks -| Hook | where | description -|--- |--- |--- -| 10-before-backup | backup.sh | at the beginning of the backup -| 12-before-db-service | localdump.sh | before starting a backup of a backup type (mysql, sqlite, ...) -| 14-before-db-dump | unused -| 16-after-db-dump | unused -| 18-after-db-service | localdump.sh | after finishing a database type -| 20-before-transfer | transfer.sh | before starting transfer of all directories -| 22-before-folder-transfer| transfer.sh | before starting transfer of a single directory -| 24-after-folder-transfer | transfer.sh | after transfer of a single directory -| 26-after-prune | transfer.sh | after pruning data -| 28-after-verify | transfer.sh | after verifying data -| 30-post-backup | transfer.sh | after all backup steps - -At the beginning the startup hook (10-before-backup) and the post hook (30-post-backup) for triggering a message might be the most common to use. +| Hook | where | description +|--- |--- |--- +| 100-before-backup | backup.sh | at the beginning of the backup +| 200-before-db-service | localdump.sh | before starting a backup of a backup type (mysql, sqlite, ...) +| 210-before-db-dump | unused +| 220-after-db-dump | unused +| 230-after-db-service | localdump.sh | after finishing a database type +| 300-before-transfer | transfer.sh | before starting transfer of all directories +| 310-before-folder-transfer| transfer.sh | before starting transfer of a single directory +| 320-after-folder-transfer | transfer.sh | after transfer of a single directory +| 330-after-prune | transfer.sh | after pruning data +| 340-after-verify | transfer.sh | after verifying data +| 400-post-backup | transfer.sh | after all backup steps + +At the beginning the startup hook (100-before-backup) and the post hook (400-post-backup) for triggering a message might be the most common to use. ## Subdirs of a hook dir @@ -49,37 +49,37 @@ After execution of the scripts of "on-ok" or "on-error" additionally the found s ```txt > tree -d hooks/ hooks/ -|-- 10-before-backup +|-- 100-before-backup | `-- always -|-- 12-before-db-service +|-- 200-before-db-service | `-- always -|-- 14-before-db-dump +|-- 210-before-db-dump | `-- always -|-- 16-after-db-dump +|-- 220-after-db-dump | |-- always | |-- on-error | `-- on-ok -|-- 18-after-db-service +|-- 230-after-db-service | |-- always | |-- on-error | `-- on-ok -|-- 20-before-transfer +|-- 300-before-transfer | `-- always -|-- 22-before-folder-transfer +|-- 310-before-folder-transfer | `-- always -|-- 24-after-folder-transfer +|-- 320-after-folder-transfer | |-- always | |-- on-error | `-- on-ok -|-- 26-after-prune +|-- 330-after-prune | |-- always | |-- on-error | `-- on-ok -|-- 28-after-verify +|-- 340-after-verify | |-- always | |-- on-error | `-- on-ok -`-- 30-post-backup +`-- 400-post-backup |-- always |-- on-error `-- on-ok @@ -96,9 +96,9 @@ When processing a hook all files will be sorted in alphabetic order. Files start Before the backup starts we want to update some local information that we want to put as latest information. I have a script that gets the list of installed linux packages as a textfile. If my system is damaged and I need to reinstall it this list will help me to reinstall all applications and libraries. -If my bash script that does the job is `/home/axel/scripts/list_packages.sh` ... and we let it run on each start of the backup. That's why we use the *10-before-backup* hook: +If my bash script that does the job is `/home/axel/scripts/list_packages.sh` ... and we let it run on each start of the backup. That's why we use the *100-before-backup* hook: -Create a file named *hooks/10-before-backup/always/10_list_packages.sh* which has the content: +Create a file named *hooks/100-before-backup/always/10_list_packages.sh* which has the content: ```sh #!/usr/bin/env bash @@ -107,8 +107,8 @@ Create a file named *hooks/10-before-backup/always/10_list_packages.sh* which ha If you have the installation in a user directory keep in mind that the backup runs as root. Set executable permissions for root. If owner and group is your user then set exection permissions for the world: 0755: ```sh -> chmod 0755 hooks/10-before-backup/always/10_list_packages.sh -> ls -l hooks/10-before-backup/always +> chmod 0755 hooks/100-before-backup/always/10_list_packages.sh +> ls -l hooks/100-before-backup/always total 4 -rwxr-xr-x 1 axel axel 79 Oct 7 22:36 10_get_installed_packages.sh ``` diff --git a/helper/update_hooks.sh b/helper/update_hooks.sh new file mode 100755 index 0000000000000000000000000000000000000000..aac998c3905054f858fa8064cbc006b26ea95676 --- /dev/null +++ b/helper/update_hooks.sh @@ -0,0 +1,85 @@ +#!/bin/bash +# =============================================================== +# +# HELPER: move existing hooks to new hook structure +# +# --------------------------------------------------------------- +# 2022-11-04 axel.hahm@iml.unibe.ch +# =============================================================== + +cd "$( dirname $0 )/../hooks" + + +# --------------------------------------------------------------- +# CONFIG +# --------------------------------------------------------------- + +typeset -i iFound=0 +declare -a aOldHooks=( + 10-before-backup + 12-before-db-service + 14-before-db-dump + 16-after-db-dump + 18-after-db-service + 20-before-transfer + 22-before-folder-transfer + 24-after-folder-transfer + 26-after-prune + 28-after-verify + 30-post-backup +) + +declare -a aNewHooks=( + 100-before-backup + 200-before-db-service + 210-before-db-dump + 220-after-db-dump + 230-after-db-service + 300-before-transfer + 310-before-folder-transfer + 320-after-folder-transfer + 330-after-prune + 340-after-verify + 400-post-backup +) + +# --------------------------------------------------------------- +# MAIN +# --------------------------------------------------------------- + +echo +echo ===== HELPER: move existing hooks to new hook structure ===== +echo + +for i in ${!aOldHooks[@]} +do + hookfrom=${aOldHooks[$i]} + hookto=${aNewHooks[$i]} + + if [ -d "$hookto" ]; then + if [ -d "$hookfrom" ]; then + echo " SCAN for $hookfrom ... " + for myfile in $( find $hookfrom -type f | grep -v ".gitignore" ) + do + tofile=$( echo $myfile | sed "s#$hookfrom#$hookto#" ) + echo -n " MOVE $myfile -> $tofile ... " + mv "$myfile" "$tofile" && echo "OK" || echo "FAILED" + iFound+=1 + done + find $hookfrom -type f | grep -v ".gitignore" && echo " WARNING: some files are still in [$hookfrom] " || ( + echo -n " no more files ... REMOVE [$hookfrom] ... " + rm -rf "$hookfrom" && echo "OK" || echo "FAILED" + ) + echo + else + echo "SKIP $hookto - nothing to do." + fi + else + echo "ERROR: hook dir $hookto does not exist" + fi +done + +echo "----------------------------------------------------------------------" +echo "moved files: $iFound" + +# --------------------------------------------------------------- diff --git a/hooks/10-before-backup/always/.gitkeep b/hooks/100-before-backup/always/.gitkeep similarity index 100% rename from hooks/10-before-backup/always/.gitkeep rename to hooks/100-before-backup/always/.gitkeep diff --git a/hooks/12-before-db-service/always/.gitkeep b/hooks/200-before-db-service/always/.gitkeep similarity index 100% rename from hooks/12-before-db-service/always/.gitkeep rename to hooks/200-before-db-service/always/.gitkeep diff --git a/hooks/14-before-db-dump/always/.gitkeep b/hooks/210-before-db-dump/always/.gitkeep similarity index 100% rename from hooks/14-before-db-dump/always/.gitkeep rename to hooks/210-before-db-dump/always/.gitkeep diff --git a/hooks/16-after-db-dump/always/.gitkeep b/hooks/220-after-db-dump/always/.gitkeep similarity index 100% rename from hooks/16-after-db-dump/always/.gitkeep rename to hooks/220-after-db-dump/always/.gitkeep diff --git a/hooks/16-after-db-dump/on-error/.gitkeep b/hooks/220-after-db-dump/on-error/.gitkeep similarity index 100% rename from hooks/16-after-db-dump/on-error/.gitkeep rename to hooks/220-after-db-dump/on-error/.gitkeep diff --git a/hooks/16-after-db-dump/on-ok/.gitkeep b/hooks/220-after-db-dump/on-ok/.gitkeep similarity index 100% rename from hooks/16-after-db-dump/on-ok/.gitkeep rename to hooks/220-after-db-dump/on-ok/.gitkeep diff --git a/hooks/18-after-db-service/always/.gitkeep b/hooks/230-after-db-service/always/.gitkeep similarity index 100% rename from hooks/18-after-db-service/always/.gitkeep rename to hooks/230-after-db-service/always/.gitkeep diff --git a/hooks/18-after-db-service/on-error/.gitkeep b/hooks/230-after-db-service/on-error/.gitkeep similarity index 100% rename from hooks/18-after-db-service/on-error/.gitkeep rename to hooks/230-after-db-service/on-error/.gitkeep diff --git a/hooks/18-after-db-service/on-ok/.gitkeep b/hooks/230-after-db-service/on-ok/.gitkeep similarity index 100% rename from hooks/18-after-db-service/on-ok/.gitkeep rename to hooks/230-after-db-service/on-ok/.gitkeep diff --git a/hooks/20-before-transfer/always/.gitkeep b/hooks/300-before-transfer/always/.gitkeep similarity index 100% rename from hooks/20-before-transfer/always/.gitkeep rename to hooks/300-before-transfer/always/.gitkeep diff --git a/hooks/300-before-transfer/always/10_ensure_repo_v2.sh b/hooks/300-before-transfer/always/10_ensure_repo_v2.sh new file mode 100755 index 0000000000000000000000000000000000000000..111e4984a66dbe974bffc0bbec26f7423ae690af --- /dev/null +++ b/hooks/300-before-transfer/always/10_ensure_repo_v2.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +echo -n "UPGRADE: REPO ... " +if eval restic migrate $ARGS_DEFAULT | grep upgrade_repo_v2; then + echo "need to update to v2" + eval restic migrate upgrade_repo_v2 +else + echo "up to date" +fi +sleep 3 + +# sleep 100 +# exit \ No newline at end of file diff --git a/hooks/22-before-folder-transfer/always/.gitkeep b/hooks/310-before-folder-transfer/always/.gitkeep similarity index 100% rename from hooks/22-before-folder-transfer/always/.gitkeep rename to hooks/310-before-folder-transfer/always/.gitkeep diff --git a/hooks/24-after-folder-transfer/always/.gitkeep b/hooks/320-after-folder-transfer/always/.gitkeep similarity index 100% rename from hooks/24-after-folder-transfer/always/.gitkeep rename to hooks/320-after-folder-transfer/always/.gitkeep diff --git a/hooks/24-after-folder-transfer/on-error/.gitkeep b/hooks/320-after-folder-transfer/on-error/.gitkeep similarity index 100% rename from hooks/24-after-folder-transfer/on-error/.gitkeep rename to hooks/320-after-folder-transfer/on-error/.gitkeep diff --git a/hooks/24-after-folder-transfer/on-ok/.gitkeep b/hooks/320-after-folder-transfer/on-ok/.gitkeep similarity index 100% rename from hooks/24-after-folder-transfer/on-ok/.gitkeep rename to hooks/320-after-folder-transfer/on-ok/.gitkeep diff --git a/hooks/26-after-prune/always/.gitkeep b/hooks/330-after-prune/always/.gitkeep similarity index 100% rename from hooks/26-after-prune/always/.gitkeep rename to hooks/330-after-prune/always/.gitkeep diff --git a/hooks/26-after-prune/on-error/.gitkeep b/hooks/330-after-prune/on-error/.gitkeep similarity index 100% rename from hooks/26-after-prune/on-error/.gitkeep rename to hooks/330-after-prune/on-error/.gitkeep diff --git a/hooks/26-after-prune/on-ok/.gitkeep b/hooks/330-after-prune/on-ok/.gitkeep similarity index 100% rename from hooks/26-after-prune/on-ok/.gitkeep rename to hooks/330-after-prune/on-ok/.gitkeep diff --git a/hooks/28-after-verify/always/.gitkeep b/hooks/340-after-verify/always/.gitkeep similarity index 100% rename from hooks/28-after-verify/always/.gitkeep rename to hooks/340-after-verify/always/.gitkeep diff --git a/hooks/28-after-verify/on-error/.gitkeep b/hooks/340-after-verify/on-error/.gitkeep similarity index 100% rename from hooks/28-after-verify/on-error/.gitkeep rename to hooks/340-after-verify/on-error/.gitkeep diff --git a/hooks/28-after-verify/on-ok/.gitkeep b/hooks/340-after-verify/on-ok/.gitkeep similarity index 100% rename from hooks/28-after-verify/on-ok/.gitkeep rename to hooks/340-after-verify/on-ok/.gitkeep diff --git a/hooks/30-post-backup/always/.gitkeep b/hooks/400-post-backup/always/.gitkeep similarity index 100% rename from hooks/30-post-backup/always/.gitkeep rename to hooks/400-post-backup/always/.gitkeep diff --git a/hooks/30-post-backup/on-error/.gitkeep b/hooks/400-post-backup/on-error/.gitkeep similarity index 100% rename from hooks/30-post-backup/on-error/.gitkeep rename to hooks/400-post-backup/on-error/.gitkeep diff --git a/hooks/30-post-backup/on-ok/.gitkeep b/hooks/400-post-backup/on-ok/.gitkeep similarity index 100% rename from hooks/30-post-backup/on-ok/.gitkeep rename to hooks/400-post-backup/on-ok/.gitkeep diff --git a/localdump.sh b/localdump.sh index 36abbfe34e9fe995d54b964ce3633b919482b441..a9f20d1681a6bbc283fde956ecd000fe2b1c339b 100755 --- a/localdump.sh +++ b/localdump.sh @@ -15,6 +15,7 @@ # 2021-07-13 ..... remove leading ./ in localdump.sh restore # 2022-02-18 ..... WIP: use class like functions # 2022-03-17 ..... WIP: add lines with prefix __DB__ +# 2022-11-04 ah rename hooks # ====================================================================== # --- variables: @@ -354,9 +355,9 @@ # ----- start service specific script h2 "START SCRIPT FOR ${SERVICENAME} - $BACKUP_SCRIPT" - _j_runHooks "12-before-db-service" + _j_runHooks "200-before-db-service" . $BACKUP_SCRIPT $mode - _j_runHooks "18-after-db-service" "$rc" + _j_runHooks "230-after-db-service" "$rc" # ----- post jobs: cleanup cleanup_backup_target diff --git a/plugins/transfer/restic.sh b/plugins/transfer/restic.sh index ba4d0cce82105efa8f4d0206cc95e11ff14c2156..73035acfad0fc3ab6b8664253e37bca6c4c7c1a4 100644 --- a/plugins/transfer/restic.sh +++ b/plugins/transfer/restic.sh @@ -15,6 +15,7 @@ # 2022-05-10 ah v0.5 fix handling with nocache flag (use globally as default param - not in backup only) # 2022-05-16 ah v0.6 added restic prune # 2022-10-21 ah v0.7 simplify restic exec commands in _restic; remove --prune in check +# 2022-11-04 ah v1.0 one command for forget and prune; rename hooks # ================================================================================ # -------------------------------------------------------------------------------- @@ -177,13 +178,14 @@ # return exitcode of restic prune function t_backupDoPrune(){ # -------------------- - echo "--- FORGET (in all pathes of repository)" + echo "--- FORGET AND PRUNE (in all pathes of repository)" local _tag=$( _j_getvar ${STORAGEFILE} "${CFGPREFIX}tag") local _mycmd="forget \ ${ARGS_DEFAULT} \ --tag $_tag \ --group-by paths,tags \ + --prune \ --cleanup-cache" local _keep @@ -201,13 +203,8 @@ t_rcCheckCleanup $_myrc echo - # -------------------- - echo "--- PRUNE (whole repository)" - _restic prune - _myrc=$? - t_rcCheckPrune $_myrc - _j_runHooks "26-after-prune" "$_myrc" + _j_runHooks "330-after-prune" "$_myrc" echo return $_myrc @@ -225,7 +222,7 @@ _myrc=$? t_rcCheckVerify $_myrc - _j_runHooks "28-after-verify" "$_myrc" + _j_runHooks "340-after-verify" "$_myrc" echo return $_myrc } @@ -405,16 +402,6 @@ } # verify backup data # param integer exitcode of command - function t_rcCheckPrune(){ - echo -n "__PRUNE__ " - case $1 in - 0) color ok; echo "OK" ;; - *) color error; echo "FAILED - returncode was $1" ;; - esac - color reset - } - # verify backup data - # param integer exitcode of command function t_rcCheckVerify(){ echo -n "__VERIFY__ " case $1 in diff --git a/restore.sh b/restore.sh index 2ed932e0c847d14b126724d995a7f2d84f8b47e8..ea4b4acb6ca3bc4532e89bc659209d952239c5f2 100755 --- a/restore.sh +++ b/restore.sh @@ -22,7 +22,7 @@ # 2018-08-27 ah,ds v1.2 fix restore target with a given selection; handle '*' placeholder # 2019-06-05 ah,ds v1.3 add custom cache dir # 2021-05-19 ah,ds, v2.0 plugin driven -# 2022-10-21 ah v2.1 init vars +# 2022-10-21 ah v2.1 init vars; shell fixes # ================================================================================ @@ -32,11 +32,11 @@ # . `dirname $0`/inc_config.sh - . `dirname $0`/jobhelper.sh - . `dirname $0`/inc_bash.sh + . $(dirname $0)/jobhelper.sh + . $(dirname $0)/inc_bash.sh # --- load a transfer plugin - STORAGE_BIN=`_j_getvar ${STORAGEFILE} "bin"` + STORAGE_BIN=$(_j_getvar ${STORAGEFILE} "bin") if [ -z "$STORAGE_BIN" ]; then if ! id -u | grep '^0$' @@ -50,20 +50,20 @@ CFGPREFIX=${STORAGE_BIN}_ - . `dirname $0`/plugins/transfer/$STORAGE_BIN.sh || exit 1 + . $(dirname $0)/plugins/transfer/$STORAGE_BIN.sh || exit 1 # --- get backend url of backup data - STORAGE_BASEDIR=`_j_getvar ${STORAGEFILE} "storage"` + STORAGE_BASEDIR=$(_j_getvar ${STORAGEFILE} "storage") if [ -z $STORAGE_BASEDIR ]; then - echo ERROR: missing config for backup target. - echo There must be an entry storage in ${STORAGEFILE} + echo "ERROR: missing config for backup target." + echo "There must be an entry storage in ${STORAGEFILE}" exit 1 fi # target directory of directory specific repository STORAGE_TARGETPATH= - PASSPHRASE=`_j_getvar ${STORAGEFILE} "passphrase"` + PASSPHRASE=$(_j_getvar "${STORAGEFILE}" "passphrase") # timestamp or snapshot id RESTORE_ITEM= @@ -72,7 +72,7 @@ RESTORE_FILTER= # full path of restore data - RESTORE_BASEDIR=`_j_getvar ${STORAGEFILE} "restore-path"` + RESTORE_BASEDIR=$(_j_getvar "${STORAGEFILE}" "restore-path") RESTORE_TARGETPATH= # set vars for transfer plugin @@ -80,15 +80,16 @@ # ----- Create default command line parameters + export ARGS_DEFAULT ARGS_DEFAULT="$( t_getParamDefault $1 $2 )" - sFileSshPrivkey=`_j_getvar ${STORAGEFILE} "ssh-privatekey"` - if [ ! -z $sFileSshPrivkey ]; then + sFileSshPrivkey=$(_j_getvar "${STORAGEFILE}" "ssh-privatekey") + if [ -n "$sFileSshPrivkey" ]; then ARGS_DEFAULT="${ARGS_DEFAULT} $( t_getParamSshKey $sFileSshPrivkey )" fi # task#3046 - add custom cache dir - sCacheDir=`_j_getvar ${STORAGEFILE} "cachedir"` + sCacheDir=$(_j_getvar "${STORAGEFILE}" "cachedir") ARGS_DEFAULT="${ARGS_DEFAULT} $( t_getParamCacheDir $sCacheDir )" @@ -115,7 +116,7 @@ function enterBackupDir(){ echo "Enter the full path; marked entries with (*) do not exist on this machine" echo - local sDirs="`j_getDirs2Backup`" + local sDirs="$(j_getDirs2Backup)" for mydir in $sDirs do if [ ! -d "$mydir" ]; then @@ -130,7 +131,7 @@ function enterBackupDir(){ color input echo -n "[$BACKUP_DIR] >" color reset - read myinput + read -r myinput setBackupDir "${myinput}" @@ -143,7 +144,7 @@ function enterBackupDir(){ # ---------------------------------------------------------------------- function setBackupDir(){ if [ ! -z $1 ]; then - sDirs2Backup="`j_getDirs2Backup`" + sDirs2Backup="$(j_getDirs2Backup)" bFound=0 for mydir in ${sDirs2Backup} do @@ -176,7 +177,7 @@ function setBackupDir(){ # set backup url and local restore path (based on given backup directory) function setVars(){ - local sSafeName=`j_getSafename "$BACKUP_DIR"` + local sSafeName=$(j_getSafename "$BACKUP_DIR") RESTORE_TARGETPATH="${RESTORE_BASEDIR}/${sSafeName}" STORAGE_TARGETPATH="$( t_backupDirGetTarget $BACKUP_DIR )" } @@ -193,7 +194,7 @@ function doRestore(){ fi mkdir -p "${RESTORE_TARGETPATH}" - echo $restorecmd + echo "$restorecmd" color cmd $restorecmd fetchrc @@ -205,9 +206,9 @@ function doRestore(){ echo echo Restore is finished. echo Have look to the output above. - echo "The restore path has `find ${RESTORE_TARGETPATH} | wc -l` items (`du -hs ${RESTORE_TARGETPATH} | awk '{ print $1 }'`)" + echo "The restore path has $(find ${RESTORE_TARGETPATH} | wc -l) items ($(du -hs ${RESTORE_TARGETPATH} | awk '{ print $1 }'))" echo - echo find ${RESTORE_TARGETPATH} + echo "find ${RESTORE_TARGETPATH}" exit } @@ -222,14 +223,10 @@ function doRestore(){ t_checkRequirements setBackupDir $1 - if [ -z $BACKUP_DIR ]; then + if [ -z "$BACKUP_DIR" ]; then enterBackupDir fi - # init vars of the backup tool - t_getParamDefault >/dev/null - - # ----- menu and loop while true @@ -257,7 +254,7 @@ function doRestore(){ echo " restore to : $RESTORE_TARGETPATH" echo -n " " if [ -n "$RESTORE_TARGETPATH" ]; then - ls -d $RESTORE_TARGETPATH >/dev/null 2>&1 + ls -d "$RESTORE_TARGETPATH" >/dev/null 2>&1 if [ $? -eq 0 ]; then color error echo "WARNING: directory already exists! Backup will fail." @@ -274,7 +271,7 @@ function doRestore(){ echo showPrompt "Select (not case sensitive) --> " - read action + read -r action echo case $action in @@ -296,7 +293,7 @@ function doRestore(){ h2 "Search a file" filefilter=".*" showPrompt "Regex for filefilter; ${filefilter} for all >" - read filefilter + read -r filefilter test -z "${filefilter}" || t_restoreDoSearchFile "${filefilter}" ;; # v|V) @@ -306,7 +303,7 @@ function doRestore(){ h2 "Shell" echo "HINT: type exit in the subshell to return to the menu." echo - export PS1="RESTIC [`basename $0` \u@\h \w]\$ " + export PS1="RESTIC [$(basename $0) \u@\h \w]\$ " bash --noprofile ;; f|F) diff --git a/transfer.sh b/transfer.sh index ccdd6464d0b8c3d10b40dc377af3524fe5aa279c..5f3ee88476d2c5db31dc51e3fb51c84d8bb8df1e 100755 --- a/transfer.sh +++ b/transfer.sh @@ -35,6 +35,7 @@ # 2022-10-07 ah v2.5 unescape regex with space to prevent "grep: warning: stray \ before white space" # 2022-10-20 ah v2.6 move hook 20-before-transfer (after init of the backup tool) # 2022-10-21 ah v2.7 shell fixes; +# 2022-11-04 ah v2.8 rename hooks # ================================================================================ @@ -313,7 +314,7 @@ function setAction(){ # -------------------------------------------------------------------------------- # ----- PRE transfer - _j_runHooks "20-before-transfer" + _j_runHooks "300-before-transfer" h2 "$( date ) Wait for a free slot" @@ -390,7 +391,7 @@ function setAction(){ echo "SKIP backup" else - _j_runHooks "22-before-folder-transfer" + _j_runHooks "310-before-folder-transfer" sCmd="$( t_backupDirGetCmdBackup )" echo "what: ${BACKUP_DIR}" @@ -404,7 +405,7 @@ function setAction(){ echo t_rcCheckBackup $myrc "${BACKUP_DIR}" - _j_runHooks "24-after-folder-transfer" "$myrc" + _j_runHooks "320-after-folder-transfer" "$myrc" fi echo @@ -496,7 +497,7 @@ function setAction(){ fi color reset - _j_runHooks "30-post-backup" "$rc" + _j_runHooks "400-post-backup" "$rc" echo typeset -i TIMER_TRANSFER TIMER_TRANSFER=$(date +%s)-$TIMER_TRANSFER_START