How to completely remove a NetWorker client

I've worked on too many customer sites where NetWorker clients have been removed incorrectly via the command-line, or even via the console interface, but somehow the associated client file index still remains.;

Whilst NMC is a good tool for adding and removing clients, it's not the most reliable tool when it comes to cleaning up after itself. nsradmin and the command-line have always been my friend.

I created this post as a quick how to guide to removing a backup client under NetWorker in it's entirety (lock, stock and barrel).

CAUTION: Before you begin to remove a client, make sure you have a recent/valid bootstrap backup; If we make any mistakes down the line we can easily recover.

Client Side (optional)

If the client no longer has a requirement to be backed up by the NetWorker server, we can perform one or all of the following:

  • Simply stop the NetWorker daemons/services on the client
  • Remove the package/binaries from the client — There is no problem with leaving the client software installed and running, it'll just sit there doing nothing until it gets a request from a backup server.

NOTE: You can't just stop the daemons/services on the client and think that's it; you need to disable the client in the save groups, and/or remove its configuration on the NetWorker server.

Server Side

The actions needed on the server side requires a little more thought as its a little trickier, In a nutshell the following steps are required:

  1. Delete all the client savesets
  2. Delete the client file index
  3. Remove the client entries from the media database
  4. Remove client resources on the NetWorker server
  5. Remove client resources from the NetWorker software repository

Here are the steps again, with the actual commands I use to perform each task:

  1. Delete savesets for a NetWorker client:
    root@nwsvr# for SSID in `mminfo -av -r 'ssid(53)' -c <client>`
    do
       echo $SSID
       nsrim -d -y -S $SSID
    done
    Replace <client> with the actual NetWorker client you wish to delete.
  2. Delete the client file index
    root@nwsvr# nsrck -YR <client>
    root@nwsvr# rm -r /nsr/index/<client>
  3. Remove client entries from the media database
    root@nwsvr# nsrim -c <client> -X
  4. Remove the client resources from the backup server
    root@nwsvr# echo "delete type: NSR client; name: <client>" | \
       nsradmin -i -
  5. Remove client entries from the software repository
    root@nwsvr# echo "delete type: NSR Installed Software; name: <client>" | \
       nsradmin -d /nsr/res/cpdb -i -

As a seasoned backup administrator and implementer I've had to run through the above a good few hundred times. To save time I cobbled the above together in a script, and added some sanity checks into the process; It's that simple.

Here's a sample of the output from my script:

root@nwsvr# ./remove-networker-client.ksh
================================================================================
remove-networker-client.ksh (1.0.4)
This script removes a CLIENT from the Backup Server by performing the following:

  1. Deletes all savesets for a given client
  2. Deletes the client file index
  3. Removes all references in the media database for the client
  4. Removes client configuration and resources from the backup server
  5. Removes client entries from the backup software repository

 ***   USE WITH CAUTION   ***   USE WITH CAUTION   ***   USE WITH CAUTION   ***
 ***   USE WITH CAUTION   ***   USE WITH CAUTION   ***   USE WITH CAUTION   ***
--------------------------------------------------------------------------------

Which client do you want to delete?
alpha99

Do you want to delete client "alpha99" [y/n]?
y

Deleting client "alpha99" will also delete all it's savesets, are you sure [y/n]?
y

--------------------------------------------------------------------------------
removing client "alpha09"...

Deleting savesets...
f8730817-00000006-9d2c836e-532c836e-3766000b-5de57b88
2de04daf-00000006-b76d12c4-536d12c4-014a000b-5de57b88
080e4dcd-00000006-c9765092-53765092-0e38000b-5de57b88
   :
   :
8cc9e19a-00000006-ba6d128a-536d128a-0147000b-5de57b88
f2850a76-00000006-e1764f86-53764f86-0e20000b-5de57b88

Deleting client file index...
9503:nsrck: WARNING: -R will completely remove the following file indices:

    alpha99

If it was not your intent to completely remove the above
client file indices, kill this command now.  You have 6 seconds.

If it was not your intent to completely remove the above
client file indices, kill this command now.  You have 4 seconds.

If it was not your intent to completely remove the above
client file indices, kill this command now.  You have 2 seconds.

Pruning Media Database...
86069:nsrim: Processing 1 clients
86068:nsrim: Managing 308 volumes.
Avamar: 1642 GB used,  4206 save sets, appendable, 4165 browsable save sets, 41 recoverable save sets
schlumpf05.005:    0 KB used,     0 save sets, appendable (manual recyclable)
schlumpf05.VDrive.001:  266 TB used,  1717 save sets, appendable, 1712 browsable save sets, 5 recoverable save sets
   :
   :
CI4027:  394 GB used,   352 save sets, full, 7 recoverable save sets, 345 recyclable save sets
CI4028:  374 GB used,   124 save sets, full, 104 browsable save sets, 20 recoverable save sets
86073:nsrim: Compressing media database.

Deleting client...
deleted resource id 2.17.51.241.0.0.0.0.0.0.0.0.74.147.204.1.150.3.29.8(16)
deleted resource id 2.46.51.241.0.0.0.0.0.0.0.0.74.147.204.1.150.3.29.8(14)

Removing client from software repository...
deleted resource id 0.35.81.31.0.0.0.0.0.0.0.0.80.18.82.115.172.20.176.28(2)
deleted resource id 0.215.14.228.0.0.0.0.0.0.0.0.78.239.43.17.172.20.176.28(3)
deleted resource id 0.34.81.31.0.0.0.0.0.0.0.0.80.18.82.115.172.20.176.28(2)
================================================================================

You can download a copy of my script, here