diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..ceca99588e7378d70c56c46c90f5cad23d8e50dc --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# ignore files of a local instance +inc_config.sh +log/c* diff --git a/backup-status.sh b/backup-status.sh index fa754b5c0fc35baa87bb15ffb8f811cfaedd23a7..644ef80534f07ac2a81c97b354769048f704890c 100755 --- a/backup-status.sh +++ b/backup-status.sh @@ -8,6 +8,7 @@ # 2018-02-14 v1.1 hahn configure time limit # 2019-10-20 v1.3 hahn source inc_config.sh # 2020-12-07 v1.4 hahn deactivate backup +# 2021-06-16 v1.5 hahn handle multiple backup tools # ---------------------------------------------------------------------- @@ -15,7 +16,7 @@ cd ${sBackupBasedir} || exit 1 -sVersion=1.4 +sVersion=1.5 typeset -i iErrors=0 typeset -i iHours=36 typeset -i iMinutes=$iHours*60 @@ -60,7 +61,7 @@ function _getFileAge(){ function getServers(){ # ls -1 | fgrep "iml.unibe.ch" - ls -1 | grep -Ev "^(_active|SOMETHINGELSE)" + ls -1d */* | grep -Ev "/(_active|#recycle|SOMETHINGELSE)" } @@ -94,7 +95,7 @@ function _checkDir(){ echo else - echo "SKIP: $mydir won't be scanned." + echo "SKIP: $mydir won't be scanned. It isn't a directory." fi } @@ -118,43 +119,41 @@ echo echo "changed files last $iHours hours and used diskspace:" echo # _checkDir . -echo -echo "... and by server and backup sets:" -echo - - for myserver in `getServers` - do - color head - echo ----- $myserver - color reset +# echo +# echo "... and by server and backup sets:" +# echo +for myserver in `getServers` +do + color head + echo ----- SERVER: $myserver + color reset + echo + if [ -f $myserver/$sInactiveFile ]; then + du -hs $myserver echo - if [ -f $myserver/$sInactiveFile ]; then - du -hs $myserver - echo - echo "INFO: server is marked as inactive." - ls -l $myserver/$sInactiveFile - cat $myserver/$sInactiveFile - typeset -i iAge=`_getFileAge "$myserver/$sInactiveFile"` - typeset -i iDays=$iKeepBackups-$iAge/60/60/24 - # echo Age: $iAge s - if [ $iDays -lt 0 ]; then - color error - echo "ERROR: Outdated backup was found! You can delete data for $myserver." - color reset - iErrors=$iErrors+1 - else - echo "INFO: keeping it $iKeepBackups d .. $iDays d left." - fi + echo "INFO: server is marked as inactive." + ls -l $myserver/$sInactiveFile + cat $myserver/$sInactiveFile + typeset -i iAge=`_getFileAge "$myserver/$sInactiveFile"` + typeset -i iDays=$iKeepBackups-$iAge/60/60/24 + # echo Age: $iAge s + if [ $iDays -lt 0 ]; then + color error + echo "ERROR: Outdated backup was found! You can delete data for $myserver." + color reset + iErrors=$iErrors+1 else - echo - _checkDir $myserver - for subdir in `ls -1 $myserver` - do - _checkDir $myserver/$subdir - done + echo "INFO: keeping it $iKeepBackups d .. $iDays d left." fi - echo - done + else + _checkDir $myserver + echo $myserver | grep "restic-backup" > /dev/null || for subdir in `ls -1 $myserver` + do + _checkDir $myserver/$subdir + done + fi + echo +done # --- show result @@ -164,7 +163,7 @@ if [ $iErrors -eq 0 ]; then echo "OK" else color error - echo "$iErrors Errors detected." + echo "Found errors: $iErrors" fi color reset