A Simple Example of EMC Networker Customized Backup Command

Recently I got a task to run a command or script to delete files in a given folder after a success backup. In general, there are two major ways, one way is to use PowerShell script and include Networker backup command, and the other way is to use EMC Networker customized backup command. I chose to use the second way because it is more closely integrated with Networker and easier to manage and monitor.

I follow the steps as below:

  • Step 1: In the client host, create a file save001.bat under c:\Program Files\EMC NetWorker\nsr\bin.
  • Step 2: Use txt editor to edit the Save001.bat with the script listed in the following post.
  • Step 3: Login to NMC, in the Backup Command attribute of the Client resource, type the name of the backup script, save001.bat in our case.

There are some requirements listed in Networker Administrator Guide, I just listed some key ones as below:

  • The program name must begin with either the prefix save or nsr and must not exceed 64 characters.
  • The program must reside on the client in the same directory as the NetWorker save command.
  • Always specify the full path of the save command in the script.
  • The NetWorker save command must be used in the backup program.
  • All commands within the program file must complete successfully. Otherwise, the NetWorker server cannot complete the remaining instructions.

Below is the script I used by modifying the EMC example with below three steps:

  1. Run a set of pre-save commands before each save set backup (option);
  2. Back up the data by using the NetWorker save command; and
  3. If back is a success, delete the c:\temp001 folder and recreated a new empty folder.

 

REM THIS IS THE NETWORKER CUSTOMIZED COMMAND

ECHO =====NetWorker PRE SAVE COMMAND (OPTION) =======
REM PRE-SAVE COMMAND START
ECHO Networker pre save commands
REM RRE-SAVE COMMAND END

ECHO =====NetWorker SAVE COMMAND =======
REM PARSE ALL INCOMING ARGUMENTS
REM and pass single argument in case
REM more than 10 arguments are passed to this file
REM (ie %0-%9 is not enough)

SHIFT
SET arg=%0

:loop
SHIFT
IF %0.==. GOTO save
SET arg=%arg% %0
GOTO loop

:save
c:\Program Files\EMC NetWorker\nsr\bin\save.exe %arg%

ECHO =====NetWorker POST-SCRIPT COMMAND (OPTION) =======

REM POST-SAVE COMMAND START
SET /A rt=%ERRORLEVEL%

REM BACKUP SUCCESS ACTION
IF %rt% EQU 0 (
echo "backup success!!"
REM MODIFY BELOW EXAMPLE ACTIONS IF NEEDED
RMDIR /S /Q C:\temp001
MKDIR  C:\temp001
)
REM POST-SAVE COMMAND END

 

Leave a Reply

Your email address will not be published. Required fields are marked *