Veritas-bu

[Veritas-bu] bad image header

2002-05-15 19:24:09
Subject: [Veritas-bu] bad image header
From: fx AT veritas DOT com (fx)
Date: Thu, 16 May 2002 01:24:09 +0200
 And by the way, in case it could be usefull to anyone, following
is a small CMD script which will look for empty image and
eventually expire them.

 Usual disclaimer takes place here, don't blame me if the dog bites
you for using this script. I'll port this to sh one day I'll have
time or if paid ;-)

   -=oOo=-

@Echo off

@Rem Look for empty images and delete them if wanted.

@Rem François-Xavier Peretmere - fx AT Veritas DOT com
@Rem Copyright Veritas Software 11/2001

@Rem $VRTScprght$
@Rem
@Rem $Header:
C:\\Home\\fx\\RCS\\C\\Home\\fx\\Scripts\\NetBackup\\catalog\\search_empty_if.cmd,v
1.3 2002-03-14 20:13:32+01 fx Exp fx $
@Rem
@Rem $Id: search_empty_if.cmd,v 1.3 2002-03-14 20:13:32+01 fx Exp fx $
@Rem
@Rem $Log: search_empty_if.cmd,v $
@Rem Revision 1.3  2002-03-14 20:13:32+01  fx
@Rem - Added NetBackup version test
@Rem
@Rem Revision 1.2  2001-12-10 05:06:04+01  fx
@Rem - Minor bug correction with -client
@Rem
@Rem Revision 1.1  2001-11-13 12:59:30+01  fx
@Rem - Added delete & force options
@Rem - Added VRoot var. test at beginning
@Rem
@Rem Revision 1.0  2001-11-13 12:19:43+01  fx
@Rem Initial revision
@Rem
@Rem

@SetLocal ENABLEEXTENSIONS
@set myname=%~n0%~x0

@Rem NetBackup install root dir
@if z"%VRoot%" == z"" set VRoot=C:\Veritas
@if not exist %VRoot% echo %myname%: Veritas directory %VRoot% not found ! && 
goto
_exit


@rem Default parameters

@rem Default master server
set master=%COMPUTERNAME%

@Rem check we're running WinNT or W2k
if not defined OS goto _err_wrong_os
if %OS% == Windows_NT goto _after_check_os
goto _err_wrong_os
:_after_check_os

set btype=MS-Windows-NT

set delete=n
set force=
set verbose=n
set client=

:_get_param

:_begin_loop
  if "%1" == "" goto _end_params
  if %1 == -m goto _set_param_master
  if %1 == -d goto _set_param_delete
  if %1 == -delete goto _set_param_delete
  if %1 == -f goto _set_param_force
  if %1 == -force goto _set_param_force
  if %1 == -c goto _set_param_client
  if %1 == -client goto _set_param_client
  if %1 == -ct goto _set_param_btype
  if %1 == -v goto _set_param_verbose
  if %1 == -h goto _usage
goto _end_params
@rem ------

:_set_param_master
  shift
  set master=%1
  shift
  goto _begin_loop

:_set_param_delete
  shift
  set delete=o
  goto _begin_loop

:_set_param_force
  shift
  set force=-force
  goto _begin_loop

:_set_param_client
  shift
  set client=%1
  shift
  goto _begin_loop

:_set_param_btype
  shift
  set btype=%1
  shift
  goto _begin_loop

:_set_param_verbose
  shift
  set verbose=o
  goto _begin_loop

:_end_params


set NBRoot="%VRoot%\NetBackup"
set MMRoot="%VRoot%\VolMgr"

set OldPath=%PATH%
set PATH="%NBRoot%\bin";"%NBROOT%\bin\admincmd";"%MMRoot%\bin";%PATH%

@Rem Check NetBackup version
if not exist %NBRoot%\version.txt echo %myname%: %NBRoot%\version.txt not found 
! &&
goto _exit

set NBVersion=Unknown

findstr VERSION %NBRoot%\version.txt | findstr 3.4 >NUL
if errorlevel 1 goto _ver_next_1
set NBVersion=34 && goto _ver_ok

:_ver_next_1
findstr VERSION %NBRoot%\version.txt | findstr 4.5 >NUL
if errorlevel 1 echo unknown version. && goto _exit
set NBVersion=45 && goto _ver_ok

echo Must not be here. Bug or new NB version?
goto _exit

:_ver_ok
echo %nbversion%

@Rem lowercase master server name - in case vopie is on
set tm=%master:A=a%
set tm=%tm:B=b%
set tm=%tm:C=c%
set tm=%tm:D=d%
set tm=%tm:E=e%
set tm=%tm:F=f%
set tm=%tm:G=g%
set tm=%tm:H=h%
set tm=%tm:I=i%
set tm=%tm:J=j%
set tm=%tm:K=k%
set tm=%tm:L=l%
set tm=%tm:M=m%
set tm=%tm:N=n%
set tm=%tm:O=o%
set tm=%tm:P=p%
set tm=%tm:Q=q%
set tm=%tm:R=r%
set tm=%tm:S=s%
set tm=%tm:T=t%
set tm=%tm:U=u%
set tm=%tm:V=v%
set tm=%tm:W=w%
set tm=%tm:X=x%
set tm=%tm:Y=y%
set tm=%tm:Z=z%
set master=%tm%

@Rem default client list

if "%client%" == "" for /f "tokens=2"  %%c in ('bpclclients -allunique 
-noheader -l')
do call :_search_if %%c
if not "%client%" == "" call :_search_if %client%

goto _exit

:_search_if
if "%1" == "" goto _end
set client=%1
if %verbose% == o echo Searching for client %1...


for /f "tokens=1,6,19,20" %%i in ('bpimagelist -ct %btype% -client %client% -d
01/01/1970') do if %%i == IMAGE if %%l == 0 call :_doit %%j %%l

goto _end

:_doit
echo %1 - size %2

if not %delete% == o goto _exit

bpexpdate -M %master% -d 0 %force% -backupid %1

goto _exit


@rem --- _search_if ---

:_usage
echo Usage: %myname% [-delete [-force]] [-c client] [-ct classtype] [-m master]
goto _end


:_err_wrong_os
echo %myname%: This script if for real win32 OS (Windows NT/2000/XP). >&2
goto _exit

:_exit
if not "%OldPath%" =="" set PATH=%OldPath%

:_end

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