cancel
Showing results for 
Search instead for 
Did you mean: 

DOS batch script that lists all policy name that each client writes to

Zoggy_Stardust
Level 2
I need to list all policy name, client name, Active as we know there are duplicate backups So I run bppllist -U -byclient And it gives what I need for one as expected. Policy Name HW/OS/Client Active yes or no I need that for 400 + clients so how to pass each client to that command using a dos script? I know how to in UNIX so its dos I need. Or can I list all policies and sort by client for 400+ Have basic opscenter license so canned reports only
3 REPLIES 3

sdo
Moderator
Moderator
Partner    VIP    Certified

Another way to achieve the same thing, is to list all policies, and then list each client in each policy, and then sort the output.

.

@echo off
setlocal enabledelayedexpansion

set z_script_path=%~dp0
set z_script_name=%~n0

set z_file_csv=!z_script_path!!z_script_name!.csv
set z_file_lis=!z_script_path!!z_script_name!.lis
set z_file_log=!z_script_path!!z_script_name!.log
set z_file_pol=!z_script_path!!z_script_name!.pol
set z_file_tmp=!z_script_path!!z_script_name!.tmp


if exist "!z_file_csv!"  del "!z_file_csv!"
if exist "!z_file_lis!"  del "!z_file_lis!"
if exist "!z_file_pol!"  del "!z_file_pol!"
if exist "!z_file_tmp!"  del "!z_file_tmp!"


set /a z_policy_count=0
set /a z_client_count=0


call :log ""
call :log "Listing policies..."
bppllist >"!z_file_pol!" 2>&1
set z_sts=!errorlevel!
if not !z_sts!==0 (
  call :log "...call to bppllist failed, status `!z_sts!`, script aborting..."
  goto :end
)
call :log "...done..."


call :log ""
call :log "Listing clients in policies..."
for /f "tokens=1" %%a in ('type "!z_file_pol!"') do (
  set z_policy_name=%%a
  call :log "...listing policy `!z_policy_name!`..."
  bppllist !z_policy_name! >"!z_file_tmp!" 2>&1
  set z_sts=!errorlevel!
  if !z_sts!==0 (
    call :r_process_policy
  ) else (
    call :log "...failed to list policy, status `!z_sts!`, script continuing..."
  )
)
call :log "...policies read:   !z_policy_count!"
call :log "...clients listed:  !z_client_count!"
call :log "...done..."


call :log ""
call :log "Sorting..."
sort "!z_file_lis!" /o "!z_file_csv!"
set z_sts=!errorlevel!
if not !z_sts!==0 (
  call :log "...call to sort failed, status `!z_sts!`, script aborting..."
  goto :end
)
call :log "...output file is:  !z_file_csv!"
call :log "...done..."


:end
call :log ""
call :log "Script exiting..."
echo+
pause
exit /b


:r_process_policy
set /a z_policy_count+=1
for /f "tokens=1,2,3,4" %%a in ('type "!z_file_tmp!"') do (
  if "%%a"=="CLIENT" (
    set z_client_name=%%b
    set z_client_hardware=%%c
    set z_client_os=%%d
    (echo !z_client_name!,!z_client_hardware!,!z_client_os!,!z_policy_name!)>>"!z_file_lis!"
    set /a z_client_count+=1
  )
)
goto :eof


:log
(echo !date! !time:~0,8!  %~1)
(echo !date! !time:~0,8!  %~1)>>"!z_file_log!"
goto :eof

sdo
Moderator
Moderator
Partner    VIP    Certified

The script assumes that you have the path to the NetBackup binaries already defined in your system wide "PATH".

See mph999's super post about making your life easier with NetBackup:

https://www.veritas.com/community/articles/making-your-life-easier-netbackup

 

sdo
Moderator
Moderator
Partner    VIP    Certified
Let me know if you need the script to ignore de-activated policies and/or offline clients.