Networker

Re: [Networker] Deleting client entries under /nsr/index

2004-06-15 17:15:49
Subject: Re: [Networker] Deleting client entries under /nsr/index
From: Ed Skolnik <eskolnik AT INTERPUBLIC DOT COM>
To: NETWORKER AT LISTMAIL.TEMPLE DOT EDU
Date: Tue, 15 Jun 2004 16:15:05 -0500
I use the following to delete clients

#!/usr/bin/ksh   
# 
###############################################################################
#AUTHOR: Ed Skolnik 
#MODIFIED: 2003/08/11 Created 
# Purpose to properly To properly delete a Legato Networker client 
# and to clean up all Legato Networker databases. 
# The nsradmin program does not purge the Media or Client file Index's 
#
# 
###############################################################################
display_message () {
        case $1 in
                A|a) message_level="ALERT";;
                I|i) message_level="INFORMATION";;
                W|w) message_level="WARNING";;
                *)   message_level="";;
        esac
        if [ -r $tmpmessage -a -w $tmpmessage ]; then
             :
          else
           echo "$(basename $0) Error in calling display_message function "
           exit 69
        fi
        mailx -s"$message_level $(basename $0) $(uname -n) $message_level $(who 
am i | awk '{print $1}' )"  -c $mailto < $tmpmessage
        cat $tmpmessage
        rm $tmpmessage
          }
 
# ###################################################################
# #  M A I N  L I N E
# ##################################################################
#
# Declare  environment variables here 
#
nsrlog=/nsr/logs/daemon.log
mailto='root mlovreta AT interpublic DOT com'
tmpmessage=/tmp/$(basename $0)_message.$$
tmpclients="/tmp/$(basename $0)_clients.$$"
# 
if  [ $# -ne 1 ]; then
  echo " "
  echo "usage: "
  echo "$0 clientname "
  echo " "
  echo "Aborted "
  exit 69
fi
touch /tmp/a.$$
root=`ls -l /tmp/a.$$ | awk '{print $3}'`
rm /tmp/a.$$
if [ "$root" = "root" ];then
  :
 else
  echo "In order to run this script you must be root"
  exit 
fi
client="${1:-nowayinhell}"
echo "client $client"
nsradmin <<EOF | sed 's/nsradmin>//g' |sed 's/;//g' | sed 's/name://g' | sed 
's/ //g' | sort | grep -v ^$ | tail +3 | grep -v
chi-backup | tr  '[:upper:]' '[:lower:]' > $tmpclients
show name
print type:NSR client
EOF
#
if [ $(grep -c $client $tmpclients) -eq 0 ]; then
  echo "Client name $client not found, Purge aborted " > $tmpmessage
  cat $tmpclients >> $tmpmessage
  display_message W
  exit 68 
fi
  
echo "Displaying Media Database to verify "
mminfo -ot -q"client=$client" -r'volume,ssid,client,savetime(17),name' | more
echo " "
echo "Are you sure you want to delete client  $client"
echo "and all reference to the backup media ?   "
echo "Reply y or n"
read yesorno
if [ $(echo ${yesorno:-n} | tr -s '[:upper:]' '[:lower:]') = 'y' ]; then
   :
  else
   echo "Aborting purge -- No changes Made"
   exit 1
fi
echo "$(date +%m/%d/%y) $(date +%H:%M:%S) $(basename $0) \
Started for client $client " >> $nsrlog
#
echo "Begin purge of the Media database for client $client"
for I in $(mminfo -ot -q"client=$client" -r'volume,ssid,client'  | awk {'print 
$2'} ); do
 echo "nsrmm -d -y -S  $I "
 nsrmm -d -y -S  $I
 if [ $? -ne 0 ]; then
   sleep 5
   nsrmm -d -y -S  $I
   if [ $? -ne 0 ]; then
    sleep 5
    nsrmm -d -y -S  $I
   fi
 fi
done
#
if [ $(mminfo -ot -q"client=$client"  2>/dev/null | wc -l) -eq 0 ]; then
   echo "Begin process of deleting the Client $client from the resource 
database"
  else
  echo "$client still has Media database entries  " > $tmpmessage
  echo "Please restart delete process " >> $tmpmessage 
  display_message W 
  exit 67 
fi
#
 while [ ${nsradminrc:-0} -eq 0 ]; do
echo "Deleting Client Resource $client "
nsradmin -i - <<EOF
delete type:NSR client;name:$client
EOF
nsradminrc=$?
echo $nsradminrc
 done
#
echo "Deleting Client file Index for $client "
find /nsr/index/$client -type f -exec rm {} \;
find /nsr/index/$client -type d -depth -exec rmdir {} \;
#
# Clean up temp files 
find /tmp  -name "$(basename $0)*" -type f  -exec rm {} \;
echo "$(date +%m/%d/%y) $(date +%H:%M:%S) $(basename $0) Ended " >> $nsrlog 
exit 0


Ed Skolnik


-----Original Message-----
From: Dennis Schmidt [mailto:dennis.schmidt AT TDS DOT DE] 
Sent: Friday, June 11, 2004 10:16 AM
Subject: Re: Deleting client entries under /nsr/index


hi,

you will later see, if you doesn´t remove this client,at a backup of the 
backupserver this messages,because the server cannot purge
the savesets. so you can controll to,if they are old.another way is to control 
how old are your /nsr/index entries with ls -ltr and
look on your browse/retention policies and says ok,this one is old,there´s one 
old, and so on.

nice greetings,dennis



[root@backupserver logs]# grep purge daemon.log
06/11/04 10:02:05 nsrd: can't purge saveset from index <client> (`<client>' is 
not a registered client) 06/11/04 10:05:03 nsrd:
can't purge saveset from index <client> (`<client>' is not a registered client) 
06/11/04 10:05:08 nsrd: can't purge saveset from
index <client> (`<client>' is not a registered client) 06/11/04 11:52:07 nsrd: 
can't purge saveset from index <client> (`<client>'
is not a registered client) 06/11/04 12:52:47 nsrd: can't purge saveset from 
index <client>(`<client>' is not a registered client)

--
Note: To sign off this list, send a "signoff networker" command via email to 
listserv AT listmail.temple DOT edu or visit the list's Web
site at http://listmail.temple.edu/archives/networker.html where you can also 
view and post messages to the list.
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=

--
Note: To sign off this list, send a "signoff networker" command via email
to listserv AT listmail.temple DOT edu or visit the list's Web site at
http://listmail.temple.edu/archives/networker.html where you can
also view and post messages to the list.
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=

<Prev in Thread] Current Thread [Next in Thread>