diff --git a/inc_config.sh.dist b/inc_config.sh.dist index 3bbc0be898b965105083105b328d4f7640673bfa..6575ca2c618baafc0229b02de2c55d51c1fbb134 100644 --- a/inc_config.sh.dist +++ b/inc_config.sh.dist @@ -8,14 +8,20 @@ typeset -i iMaxConnections=10 typeset -i iConnections + sSelfdir="$( dirname $0 )" + # directory with backup data - sBackupBasedir="/netshare/one-backup" + # sublevel 1 is a name of backup tool + # sublevel 2 is a fqdn of a backed up server + # i.e. /netshare/restic-backup/server.example.com + sBackupBasedir="/netshare" # where to store current connections - sConncectionDir="$sBackupBasedir/_active" + # sConncectionDir="${sBackupBasedir}/_active" + sConncectionDir="${sSelfdir}/_active_connections" # log - sLogdir="/opt/imlbackup/server/" + sLogdir="${sSelfdir}/log" sLogfile="$sLogdir/connections.log" diff --git a/storage_helper.sh b/storage_helper.sh index ea5cc21eb9dbfc1847fa36e650bc2b796a8314c2..dc1e71d18189d01ce0068f59517a59b722156098 100755 --- a/storage_helper.sh +++ b/storage_helper.sh @@ -37,6 +37,7 @@ # value is set in _showConnectionCount iConnections=0 + # ---------------------------------------------------------------------- # FUNCTIONS # ---------------------------------------------------------------------- @@ -157,11 +158,57 @@ fi } + function _listRepodirs(){ + for mydir in $( ls -1d ${sBackupBasedir}/*/* | grep -vE '(_active|somethinglsetodisable)' ) + do + echo -n "$mydir " + test -f "$mydir/inactive.txt" && ( color error ; echo -n "(inactive)" ) + test -f "$mydir/inactive.txt" || ( color ok ; echo -n "(active)" ) + color reset + echo + done + } # ---------------------------------------------------------------------- # PUBLIC FUNCTIONS # ---------------------------------------------------------------------- + + function PUBLIC_setactive(){ + echo --- list of inactive backup repositories + _listRepodirs | grep '\(inactive\)' + echo + echo -n "Repo to activate again >" + read inputdir + if [ -f "$inputdir/inactive.txt" ]; then + cat "$inputdir/inactive.txt" + echo + echo Removing $inputdir/inactive.txt + rm -f "$inputdir/inactive.txt" + echo If it was a mistake run $( basename $0 ) setinactive + else + echo SKIP [$inputdir] + fi + echo + } + + function PUBLIC_setinactive(){ + echo --- list of backup repositories + _listRepodirs + echo + echo -n "Repo to deactivate >" + read inputdir + if [ -d "$inputdir" -a ! -f "$inputdir/inactive.txt" ]; then + echo -n "Short message >" + read mymessage + echo "$( date ) | $mymessage" >"$inputdir/inactive.txt" + ls -l "$inputdir/inactive.txt" + else + echo SKIP [$inputdir] + fi + echo + } + # return backup directory for a client function PUBLIC_getBackupdir(){ setBackupclient $1 @@ -211,8 +258,10 @@ # show used slots function PUBLIC_status(){ _showConnectionCount + echo if [ $iConnections -gt 0 ]; then - find $sConncectionDir -type f -exec ls -l {} \; + find $sConncectionDir -type f -exec ls -l {} \; | nl + echo fi exit 0 } @@ -308,6 +357,14 @@ echo " register | unregister [hostname]" echo " add/ remove slot for a backup client" echo + echo " setactive" + echo " Reactivate an inctave backup repo." + echo + echo " setinactive" + echo " Mark a backup repo as inactive." + echo " This prevents errors of missing backup data" + echo " if a host is obsolete and was shut down." + echo echo " status" echo " show current reserved slots" echo