Forum Discussion

Armin_Kerl's avatar
Armin_Kerl
Level 3
17 years ago

Script for deleting Old IMG Folders and BKF Files

Also in BE12 SP1 we have the problem that not always the B2D Media is deleted in the B2D Folder on the Filesystem, even the Disk Space is filling up.

The Media is Overwriten and deleted as BE Media Entry, but not in the FileSystem.

 

So I have made a little Batch Script to free up the B2D Disk Space.

I add it as Post Command to the B2D Job (run on Media Server).

 

The Script reads the existing Media's known by the BE B2D Device.

This Media's are compared to the  existing Media's in the Filesystem Folder.

All BKF Files and IMG Folders that no longer exist in BE are deleted.

 

(In our Config BE does not release the Handle for esent.dll is in the IMG Folders, this does "net stop winmgmt")

Before first Run, please change the rd and del command to echo for testing.

 +++++++++++++++++++++++++++++++++++

set Device=GRT-Mail1
set Folder=E:\GRT-Mail1\

if exist %Folder%Media.txt del %Folder%Media.txt
if exist %Folder%Media1.txt del %Folder%Media1.txt
if exist %Folder%Media2.txt del %Folder%Media2.txt
if exist %Folder%Dir.txt del %Folder%Dir.txt
if exist %Folder%Del.txt del %Folder%Del.txt
if exist "c:\Program Files\Symantec\Backup Exec\bemcmd.exe" set BEPath="c:\Program Files\Symantec\Backup Exec\bemcmd.exe"
if exist "c:\Programme\Symantec\Backup Exec\bemcmd.exe" set BEPath="c:\Programme\Symantec\Backup Exec\bemcmd.exe"
if BEPath=="" Echo "Kann Pfad zu BackupExec nicht finden!" & goto End

net stop winmgmt

%BEPath% -o132 -j%Device% >%Folder%Media1.txt
if not errorlevel=1 net send %computername% Fehler beim auflisten der BackupExec GRT Medien! & goto End

findstr /c:"LABEL: "  %Folder%Media1.txt >%Folder%Media2.txt
for /f "tokens=3 delims= " %%m in (%Folder%Media2.txt) do echo %%m >>%Folder%%Media.txt
for %%d in (%Folder%*.bkf) do echo %%~nd >>%Folder%Dir.txt
for /d %%d in (%Folder%*.) do echo %%~nd >>%Folder%Dir.txt

findstr /v /g:%Folder%Media.txt %Folder%Dir.txt >%Folder%Del.txt

for /f %%i in ('findstr /b IMG %Folder%Del.txt') do rd /s/q %%i
for /f %%b in ('findstr /b B2D %Folder%Del.txt') do del /f/q %%b.bkf

:End

net start winmgmt
+++++++++++++++++++++++++++

 

If it Helps You, please add a Note.

 

Armin

19 Replies