Skip to content
Snippets Groups Projects
Commit 4d12d315 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

backup-status.sh v1.5 - handle multiple backup tools

parent 3cd74416
No related branches found
No related tags found
No related merge requests found
# ignore files of a local instance
inc_config.sh
log/c*
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
# 2018-02-14 v1.1 hahn configure time limit # 2018-02-14 v1.1 hahn configure time limit
# 2019-10-20 v1.3 hahn source inc_config.sh # 2019-10-20 v1.3 hahn source inc_config.sh
# 2020-12-07 v1.4 hahn deactivate backup # 2020-12-07 v1.4 hahn deactivate backup
# 2021-06-16 v1.5 hahn handle multiple backup tools
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -15,7 +16,7 @@ ...@@ -15,7 +16,7 @@
cd ${sBackupBasedir} || exit 1 cd ${sBackupBasedir} || exit 1
sVersion=1.4 sVersion=1.5
typeset -i iErrors=0 typeset -i iErrors=0
typeset -i iHours=36 typeset -i iHours=36
typeset -i iMinutes=$iHours*60 typeset -i iMinutes=$iHours*60
...@@ -60,7 +61,7 @@ function _getFileAge(){ ...@@ -60,7 +61,7 @@ function _getFileAge(){
function getServers(){ function getServers(){
# ls -1 | fgrep "iml.unibe.ch" # 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(){ ...@@ -94,7 +95,7 @@ function _checkDir(){
echo echo
else else
echo "SKIP: $mydir won't be scanned." echo "SKIP: $mydir won't be scanned. It isn't a directory."
fi fi
} }
...@@ -118,43 +119,41 @@ echo ...@@ -118,43 +119,41 @@ echo
echo "changed files last $iHours hours and used diskspace:" echo "changed files last $iHours hours and used diskspace:"
echo echo
# _checkDir . # _checkDir .
echo # echo
echo "... and by server and backup sets:" # echo "... and by server and backup sets:"
echo # echo
for myserver in `getServers`
for myserver in `getServers` do
do color head
color head echo ----- SERVER: $myserver
echo ----- $myserver color reset
color reset echo
if [ -f $myserver/$sInactiveFile ]; then
du -hs $myserver
echo echo
if [ -f $myserver/$sInactiveFile ]; then echo "INFO: server is marked as inactive."
du -hs $myserver ls -l $myserver/$sInactiveFile
echo cat $myserver/$sInactiveFile
echo "INFO: server is marked as inactive." typeset -i iAge=`_getFileAge "$myserver/$sInactiveFile"`
ls -l $myserver/$sInactiveFile typeset -i iDays=$iKeepBackups-$iAge/60/60/24
cat $myserver/$sInactiveFile # echo Age: $iAge s
typeset -i iAge=`_getFileAge "$myserver/$sInactiveFile"` if [ $iDays -lt 0 ]; then
typeset -i iDays=$iKeepBackups-$iAge/60/60/24 color error
# echo Age: $iAge s echo "ERROR: Outdated backup was found! You can delete data for $myserver."
if [ $iDays -lt 0 ]; then color reset
color error iErrors=$iErrors+1
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
else else
echo echo "INFO: keeping it $iKeepBackups d .. $iDays d left."
_checkDir $myserver
for subdir in `ls -1 $myserver`
do
_checkDir $myserver/$subdir
done
fi fi
echo else
done _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 # --- show result
...@@ -164,7 +163,7 @@ if [ $iErrors -eq 0 ]; then ...@@ -164,7 +163,7 @@ if [ $iErrors -eq 0 ]; then
echo "OK" echo "OK"
else else
color error color error
echo "$iErrors Errors detected." echo "Found errors: $iErrors"
fi fi
color reset color reset
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment