cancel
Showing results for 
Search instead for 
Did you mean: 

NBDeployUtil Batch script

jon_warfield
Level 2
Partner

Hello, 

 

I am working on creating a BATCH script to run NBDeployUtil. At first this seems like it would be a straightforward process, but I ran in to a snag. It seems with NBDeployUtil you can set the directory for the --gather command via the --output=directory argument, but the output file name will still be variable. So when using the --report argument you need the --gather output filename. 

Is there a way to set the name of the --gather output file, or has anyone found a way to address vairable --gather output names within a batch file?

 

Thanks in advance for your advice.

6 REPLIES 6

sdo
Moderator
Moderator
Partner    VIP    Certified
NetBackup and OS version?

sdo
Moderator
Moderator
Partner    VIP    Certified

Hi Jon - do you still need a short example script to pick out the 'gather' file name and then run the report?

If so - can you post a copy of the gather command that you want to use as the starting point?

jon_warfield
Level 2
Partner

Hello, 

 

Thanks for the response. The solution I went with was just renaming the ouput with a wild card. For anyone who may be interested I have pasted the batch script below. Have not had a chance to test this in a NetBackup enviornment as of yet, but it the script looks like it is runnign correctly. Any constructive notes would be appreciated. 

 

@Echo Off
::Everything below this line will be silent

::Gathering Enviornmental Variables

::display user information
ECHO Welcome to the NetBackup Renewal Utility. Before running this Utility please read the README 

file that was included with batch script. If you do not have the README please delete this batch 

script and contact your <redacted> sales represantative. This Utility allows <Redacted> to gather pertinent 

data for the renewal of this NetBAckup Enviornment. This Utility will only run commands from the 

windows OS, and NetBackup. This utility is provided as a convenience to <redacted> customers, and is not 

required to gather the requested enviornmental information. Please see README for alternatives to 

running this batch script. By pressing ENTER you release <redacted> from any and all liability from 

using this utility.
PAUSE

::setting default master server name
SET ServerName=master

::prompting user for master server name
SET /p ServerName=Please enter the name of the master server:

::settign the default install directory 
SET InstallDirectory=C:\Program Files\Veritas\NetBackup

::prompting user for install directory of NetBackup
SET /p InstallDirectory= Please enter the install directory for NetBackup (to accept default of 

C:\Program Files\Veritas\NetBackup please press enter)

::Setting default path for report Output
SET ReportDirectory=C:\VeritasReport

::Prompting user for location of report ouput 
SET /p ReportDirectory=Please enter the full path of an empty directory we can store report output files to (default c:\VeritasReport):

::setting default zip output directory 
SET FinalOutput=c:\

::prompting user for zip output directory
SET \p FinalOutput=Please enter complete path to store the final zip file output (default c:\)

::Ensuring user knows we will be making the directory
Echo We will now make the report directory if it does not already exist. Press enter to continue. 
PAUSE

::Making Directory
MD "%ReportDirectory%"

::Ensuring User can see commands being run on the server
@Echo on

::run the nbdeployutil gather command
"%InstallDirectory%"\bin\admincmd\nbdeployutil --gather --output="%ReportDirectory%"

::renaming the ouput file of the gather command
RENAME "%ReportDirectory%"\* nbdeployutiloutput

::running capacity report
"%InstallDirectory%"\bin\admincmd\nbdeployutil --report --capacity "%ReportDirectory

%"\nbdeployutiloutput

::running traditional report
"%InstallDirectory%"\bin\admincmd\nbdeployutil --report --traditional "%ReportDirectory

%"\nbdeployutiloutput

::Running NBU Analyzer
"%InstallDirectory%"\bin\admincmd\bpimagelist -l -hoursago 800 > "%ReportDirectory%"\"%ServerName%"-bpimagelist.txt


Echo This batch file has completed. Please sip up and return the %ReportDirectory% file to your contact

to complete this process. If there was an error please rerun this batch file with a redirect command 

and return the results to your contact (EXAMPLE c:\renwal.bat>c:\renewalerr.txt) Please press 

ENTER to end this script.
PAUSE 

Jim-90
Level 6

For those that came looking for unix/linux version...........

This one keeps a local copy and mails out.  I use it to track monthly usage and other stats. It assumes that the script is run as the user bkupadm and can do sudo stuff plus it logs what's going on.

#!/bin/bash
#set -x
#uses the mutt mailer

# Jim McDonald, Sydney

rpt_path=/home/bkupadm/NBU/tmp/capacity_rpts 
# putting stuff in the home dir not the best, suggest a specific data area 
# cause output of this script is not small.

recipients="some_body_that_cares@backup_land.au"
now=$(date +'%d-%b-%Y_%H-%M-%S')
today=$(date +'%d-%b-%Y')
tmp_file1=$rpt_path/tmp_file1
trap "rm $tmp_file1 2>/dev/null" EXIT # last time I looked - "EXIT" only available in Linux 
                                      # otherwise use individual trap numbers 
log_file=$rpt_path/log_capacity_rpt_$now

sudo /bin/chown -Rh bkupadm /home/bkupadm/NBU/tmp/*
rm -r /home/bkupadm/NBU/tmp/capacity_rpts/*

master_server=YOUR_MASTER_HOSTNAME_HERE

sudo  /usr/openv/netbackup/bin/admincmd/nbdeployutil --gather --output=$rpt_path --log=$log_file
echo "Finished gathering data" >> $log_file
echo "========================================================" >> $log_file
echo "Creating final report" >> $log_file
gather_file=$(grep "capacity   : nbdeployutil --report --capacity" $log_file | awk  '{print $12}')
sudo /usr/openv/netbackup/bin/admincmd/nbdeployutil --report --capacity $gather_file >> $log_file
sudo /bin/chown -Rh bkupadm /home/bkupadm/NBU/tmp/*
output_dir=$(ls $rpt_path | grep $master_server)
# echo $output_dir
output_xls=$(ls $rpt_path/$output_dir | grep xls)
output_rpt=$rpt_path/$output_dir/NetBackup_Capacity_report_${today}.xls
mv $rpt_path/$output_dir/$output_xls $output_rpt

# --- Mail rpt & mv the reports directory -----------------------------------
cat << THE_END > $tmp_file1
This report is used by Symantec to reconcile our Capacity License against usage.  See attachment

Spreadsheet notes:

SUMMARY worksheet tab

Total Data Backed Up = CAPACITY TOTAL section -> CHARGED(TB) -> Total of Charged(TB)

Capacity By Policy Type:
  Lists only agent backups it does not list VMware VADP backups
  Linux & Unix backups listed as Standard backups
  NetApp listed as NDMP backups
________________________________________________________
ITEMIZATION worksheet tab
  Lists size of data protected on each server, it is not the total size of backup data stored for each server
________________________________________________________
Report generated by $0

THE_END

cat $tmp_file1 | /usr/bin/mutt -e "set from=no_reply" -e "set realname=NetBackup" -s "Report: NetBackup Capacity " -a $output_rpt -- $recipients   # the "--" may be a single "-", depending upon *nix version.
cp $output_rpt /home/bkupadm/NBU/reports/
cp $log_file  /home/bkupadm/NBU/logs/

sdo
Moderator
Moderator
Partner    VIP    Certified

FYI - I've posted a re-written script for Windows - based on Jon's idea of jacketing nbdeployutil - here:

https://www-secure.symantec.com/connect/downloads/windows-script-netbackup-run-nbdeployutil-and-two-reports

...which does not prompt for any user input, and detects location of NetBackup binaries, and detects the folder name created by the ---gather phase, and has error checking at every stage.  HTH.

Hello,

I am unable to access the link provided by you it says access denied, can you please provide me the script you have created.

 

https://www-secure.symantec.com/connect/downloads/windows-script-netbackup-run-nbdeployutil-and-two-...

 

Shubham