diff --git a/check_clientbackup.sh b/check_clientbackup.sh index b481c54ec1e7dcf4c09f0d890dade01511389935..899154c264f145acb4bcd62c9f3f3638d9285fd3 100755 --- a/check_clientbackup.sh +++ b/check_clientbackup.sh @@ -14,6 +14,7 @@ # 2016-12-09 ah,ds v1.0 # 2022-01-19 ah v1.1 fixes with shellcheck # 2022-02-09 ah v1.2 update after changes in logging +# 2022-10-07 ah v1.3 unescape regex with space to prevent "grep: warning: stray \ before white space" # ============================================================================== . $(dirname $0)/jobhelper.sh @@ -105,14 +106,14 @@ else # sSearch="Args:|ElapsedTime|SourceFiles|SourceFileSize|RawDeltaSize" # echo "$logfile" | grep -F "inc" >/dev/null # if [ $? -eq 0 ]; then - # sSearch="[ADM]\ |${sSearch}" + # sSearch="[ADM] |${sSearch}" # fi # echo --- changes: # grep -E "^(${sSearch})" "$logfile" echo # echo ">>> Summary of backed up directories:" - # cat $logfile | grep "DIR\ " + # cat $logfile | grep "DIR " echo ">>> Summary of backup actions:" cat $logfile | grep "__[A-Z][A-Z]*__" diff --git a/jobhelper.sh b/jobhelper.sh index f51b71629e146a58c5862beaac9f83da8ee5bda1..b72876999cc5b7cbda44b1a8bf673a8dd807eba8 100755 --- a/jobhelper.sh +++ b/jobhelper.sh @@ -12,6 +12,7 @@ # 2017-01-23 ah,ds v1.1 added j_getLastBackupAge # 2017-02-16 ah,ds v1.2 added storage helper function # 2018-02-13 ah,ds v1.3 detect samba shares based on a flag +# 2022-10-07 ah v1.4 unescape regex with space to prevent "grep: warning: stray \ before white space" # ================================================================================ @@ -130,7 +131,7 @@ function j_getDirs2Backup(){ # param string path # ------------------------------------------------------------ function j_getSetnameOfPath(){ - grep "^set.*dir\ =\ $*$" "${DIRFILE}" | cut -f 1 -d "=" | sed "s#\-\-dir\ ##g" + grep "^set.*dir = $*$" "${DIRFILE}" | cut -f 1 -d "=" | sed "s#\-\-dir ##g" } # ------------------------------------------------------------ @@ -172,7 +173,7 @@ function _j_getvar(){ >&2 echo "ERROR: cannot read file: ${1}. Abort." exit 100 fi - grep "^${2}\ =\ " < "${1}"| cut -f 3- -d " " + grep "^${2} = " < "${1}"| cut -f 3- -d " " } # ------------------------------------------------------------ @@ -196,14 +197,13 @@ function _j_runHooks(){ else _hookdir="$_hookdir/on-error" fi - - for hookscript in $( ls -1a "$_hookdir" | grep -v "^\.*$" | sort ) + for hookscript in $( ls -1a "$_hookdir" | grep -v "^\." | sort ) do - if [ -x "$hookscript" ]; then - echo ">>> HOOKS $_hookdir start $hookscript ..." - $hookscript - # else - # echo "SKIP: $hookscript (not executable)" + if [ -x "$_hookdir/$hookscript" ]; then + h3 "HOOK: start $_hookdir/$hookscript ..." + $_hookdir/$hookscript + else + h3 "HOOK: SKIP $_hookdir/$hookscript (not executable) ..." fi done @@ -336,36 +336,6 @@ function _j_setLogfile(){ export JOB_LOGFILE } -# ------------------------------------------------------------ -# date helper for job entries in start-time-inc/ start-time-full -# * get first the first entry or - if many - the latest entry -# * if empty: take value from start-time -# param string one of start-time-inc|start-time-full -# ------------------------------------------------------------ -# function _j_fetchLatestStarttime(){ -# sLatest= -# sStart=`_j_getvar ${JOBFILE} "$1" | sed "s#[\ \:\-]##g"` -# for sTime in `echo $sStart | sed "s#,# #g"` -# do -# if [ -z $sLatest ]; then -# sLatest=$sTime -# fi -# if [ $sTime -le `date +%H%M` ]; then -# sLatest=$sTime -# fi -# done -# if [ -z $sLatest ]; then -# $sLatest=`_j_getvar ${JOBFILE} "start-time" | sed "s#[\ \:\-]##g"` -# fi -# if [ -z $sLatest ]; then -# color error -# echo ERROR: missing start time info for $1 -# color reset -# exit 1 -# fi -# echo $sLatest -# } - # ------------------------------------------------------------ # check if a binary exists - and abort if not # param string name of file diff --git a/plugins/localdump/couchdb.sh b/plugins/localdump/couchdb.sh index 5015682d4b6297d15c06d3189e4a4345c3ca64f6..f948c6de165861ad9434752a079e3e2cf46ea784 100755 --- a/plugins/localdump/couchdb.sh +++ b/plugins/localdump/couchdb.sh @@ -12,6 +12,7 @@ # 2017-03-27 ..... v1.0 restore # 2022-01-20 v1.1 fixes with shellcheck # 2022-03-17 v1.2 WIP: add lines with prefix __DB__ +# 2022-10-07 ah v1.3 unescape regex with space to prevent "grep: warning: stray \ before white space" # ================================================================================ if [ -z "$BACKUP_TARGETDIR" ]; then @@ -108,7 +109,7 @@ function doBackup(){ loadInstance "$COUCHDB_INSTANCE" echo "--- instance: $COUCHDB_INSTANCE" - if curl --head -X GET "$COUCHDB_URL" 2>/dev/null | grep "^HTTP.*\ 200\ "; then + if curl --head -X GET "$COUCHDB_URL" 2>/dev/null | grep "^HTTP.* 200 "; then _doBackupOfSingleInstance @@ -186,7 +187,7 @@ function restoreByFile(){ loadInstance "$COUCHDB_INSTANCE" echo "connect $couchdbhost on port $couchdbport with user $couchdbuser" - if ! curl --head -X GET "$COUCHDB_URL" 2>/dev/null | grep "^HTTP.*\ 200\ " >/dev/null; then + if ! curl --head -X GET "$COUCHDB_URL" 2>/dev/null | grep "^HTTP.* 200 " >/dev/null; then color error echo ERROR: couch DB instance is not available curl -X GET "$COUCHDB_URL" diff --git a/plugins/localdump/couchdb2.sh b/plugins/localdump/couchdb2.sh index ea4bd3f472e650e1b93b09f72fe7084f6d1ee0d5..50a65f95d6b88158c59dbc2d0bde103b562de334 100755 --- a/plugins/localdump/couchdb2.sh +++ b/plugins/localdump/couchdb2.sh @@ -20,6 +20,7 @@ # 2022-04-07 v1.5 check archive file, not only seq file # 2022-04-14 v1.6 backup security infos (no restore yet) # 2022-04-21 v1.7 restore security infos +# 2022-10-07 ah v1.8 unescape regex with space to prevent "grep: warning: stray \ before white space" # ================================================================================ if [ -z "$BACKUP_TARGETDIR" ]; then @@ -123,7 +124,7 @@ function doBackup(){ loadInstance "$COUCHDB_INSTANCE" echo "--- instance: $COUCHDB_INSTANCE" - if curl --head -X GET "$COUCH_URL" 2>/dev/null | grep "^HTTP.*\ 200\ "; then + if curl --head -X GET "$COUCH_URL" 2>/dev/null | grep "^HTTP.* 200 "; then echo OK, connected. sleep 2 _doBackupOfSingleInstance @@ -303,7 +304,7 @@ function restoreByFile(){ if [ $bFastMode -eq 0 ]; then echo connect $couchdbhost on port $couchdbport with user $couchdbuser - curl --head -X GET $COUCH_URL 2>/dev/null | grep "^HTTP.*\ 200\ " >/dev/null + curl --head -X GET $COUCH_URL 2>/dev/null | grep "^HTTP.* 200 " >/dev/null if [ $? -ne 0 ]; then color error echo ERROR: couch DB instance is not available diff --git a/plugins/localdump/ldap.sh b/plugins/localdump/ldap.sh index 8d301aae168f187641db719c26c6e1d7fb97cf29..83ac400006ba581fa08ac8766ca8d06b6f8edf33 100755 --- a/plugins/localdump/ldap.sh +++ b/plugins/localdump/ldap.sh @@ -13,6 +13,7 @@ # 2021-12-13 ah v1.1 detect config path # 2021-12-14 ah v1.2 detect sbin path to execute slapcat without path # 2022-03-17 v1.3 WIP: add lines with prefix __DB__ +# 2022-10-07 ah v1.4 unescape regex with space to prevent "grep: warning: stray \ before white space" # ================================================================================ @@ -76,7 +77,7 @@ function doLdapBackup(){ for cfgname in $(ldapsearch -Y EXTERNAL -H ldapi:/// -s base -b '' -LLL configContext | grep "configContext" | cut -f 2 -d ":") do echo DN $cfgname - cfg2=$(echo $cfgname | sed "s#[\ =,]#_#g") + cfg2=$(echo $cfgname | sed "s#[ =,]#_#g") outfile=$(hostname)_ldap_olc_config__$(get_outfile ${cfg2}).ldif dump_ldap "$cfgname" "$BACKUP_TARGETDIR/$outfile" @@ -88,7 +89,7 @@ function doLdapBackup(){ for cfgname in $(ldapsearch -Y EXTERNAL -H ldapi:/// -s base -b "" -LLL "namingContexts" | grep "namingContexts" | cut -f 2 -d ":") do echo DN $cfgname - cfg2=`echo $cfgname | sed "s#[\ =,]#_#g"` + cfg2=`echo $cfgname | sed "s#[ =,]#_#g"` outfile=$(hostname)_ldap_data__$(get_outfile ${cfg2}).ldif dump_ldap "$cfgname" "$BACKUP_TARGETDIR/$outfile" diff --git a/plugins/transfer/duplicity.sh b/plugins/transfer/duplicity.sh index 2b1788c16734b024aa1182ddeeea06118b93d3c7..1764a95156e1f60465e04b1d4d8d32ba89cf402e 100644 --- a/plugins/transfer/duplicity.sh +++ b/plugins/transfer/duplicity.sh @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------------- # ah - Axel Hahn <axel.hahn@iml.unibe.ch> # 2021-05-19 ah v0.0 INIT ... WIP +# 2022-10-07 ah v1.1 unescape regex with space to prevent "grep: warning: stray \ before white space" # ================================================================================ @@ -211,7 +212,7 @@ local _date= echo "--- Existing snapshots:" t_restoreDoShowVolumes \ - | grep -E "(Full|Incremental).*[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\ " \ + | grep -E "(Full|Incremental).*[0-9][0-9]:[0-9][0-9]:[0-9][0-9] " \ | sort -u > $tmpoutVolumes if [ `cat $tmpoutVolumes | wc -l` -eq 0 ]; then color error diff --git a/transfer.sh b/transfer.sh index 5ec5c5fb9dffcb56675789b30df33a8d3839cc31..c90ee7270a5d5f89b78b7b952afa7d4028648df5 100755 --- a/transfer.sh +++ b/transfer.sh @@ -32,6 +32,7 @@ # 2022-02-10 ah v2.2 update logging (removing tee) # 2022-10-01 ah v2.3 customize prune and verify action # 2022-10-04 ah v2.4 prune and verify are non directory based +# 2022-10-07 ah v2.5 unescape regex with space to prevent "grep: warning: stray \ before white space" # ================================================================================ @@ -360,11 +361,11 @@ function setAction(){ if [ ! -z $backupid ]; then - for sItem in `_j_getvar ${DIRFILE} "${backupid}\-\-include" | sed "s#\ #${sSpaceReplace}#g"` + for sItem in `_j_getvar ${DIRFILE} "${backupid}\-\-include" | sed "s# #${sSpaceReplace}#g"` do ARGS_BACKUP="${ARGS_BACKUP} $( t_getParamInlude $sItem)" done - for sItem in `_j_getvar ${DIRFILE} "${backupid}\-\-exclude" | sed "s#\ #${sSpaceReplace}#g"` + for sItem in `_j_getvar ${DIRFILE} "${backupid}\-\-exclude" | sed "s# #${sSpaceReplace}#g"` do ARGS_BACKUP="${ARGS_BACKUP} $( t_getParamExlude $sItem)" done