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

update imlbackup server - 2 new functions

* added params setactive and setinactive.
* set basedir 1 level up.
parent 11384ca6
Branches
No related tags found
No related merge requests found
......@@ -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"
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment