06-27-2008 02:40 AM
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
11-14-2008 08:07 AM
Hi Armin,
can you provide details about how to run this script please?
I only seem to be able to enter a single line in the POST command text field. Should I dump your entire script into a file and call it "script.bat" and then just link to this file in the POST command text field? Or should I copy every line in seperating them with something like ; or | ?
Also, will this script run on every B2D folder or do I have to put it in the POST field of at least one backup job per B2D folder?
Many thanks
Andrew
11-15-2008 10:56 AM
11-25-2008 02:12 AM
Hi Armin,
thank you for the updated version and clearer instructions. I still have a few questions though.
1. My B2D media set is named 'B2D Folders' (including a space). Can I just put set MediaSet=B2D Folders or do I need to incase the name in speech marks like set MediaSet="B2D Folders"?
2. I cannot find a GRT folder. Should I have one of these and if so where should I look?
3. When I run the script and it errors it doesn't end the script but instead pastes everyline as normal text (see image below)
Any help you can offer is greatly appreciated.
Andrew
11-25-2008 02:40 AM
Hello Andrew,
1. Space is alwas a Problem, try it "..." or even better Rename the Media Set without using Space.
2. The GRT Folder Name is the Path you define in your Backup to Disk Device (Device > Backup-to-Disk-Folder > Your B2D Device > Properies)
In this Path you schould find the changer.cfg and the B2D... Files.
(I call it GRT Folder, because I only using B2D for GRT Mail backup.
Naming it B2D Folder schould make it clearer.)
3. I think the errors come, because the Path is not correct. Setting the Folder Name to your B2D Destination schould solve it.
Armin
12-31-2008 02:05 PM
Thanks for the work to get this put together, Armin! I really appreciated finding this.
I needed to make a couple changes to get the script to work on my server (Windows Server 2007 x64). I went ahead and formatted it and added a failsafe to ensure random execution didn't cause problems (in this version, you must specify /run in order to actually delete files, otherwise it just lists them.) Here's the revised version:
@Echo Off
:: A script to delete BKF files and IMG folders no longer needed by Backup Exec.
::
:: Original by Armin Kerl, modifications by Matthew Miller.
::
:: If you have comments or questions, please join the forum and post on the thread at:
:: https://forums.symantec.com/syment/board/message?board.id=be12_exchange&thread.id=380
::
:: Note that this will run properly only on a machine running Windows 2003 or XP SP2 with
:: command extensions turned on (which is the default on those systems).
::
:: History
:: 2008-08-19 AK Original Version
:: 2008-12-31 MM Modified to English, added formatting & comments.
:: Changed to run test only unless /run parameter is specified.
:: Added recursion through B2D subdirectories (since Backup Exec
:: adds \Veritas\B2D to all removable B2D directories on our systems)
:CONFIGURE
SETLOCAL
PUSHD
::
:: Change the following 3 items below to match your installation.
::
:: * MediaSet - the Backup Exec Media Set Name you're using for backup-to-disk jobs
:: (It's best to make this a name without spaces)
:: * B2Dfolder - the full path to the backup-to-disk folder you're using for the job
:: * BEPath - the full path to the Backup Exec executables (specifically, bemcmd.exe).
:: (If you didn't change it, this is C:\Program Files\Symantec\Backup Exec\becmd.exe,
:: on US English systems)
SET MediaSet=Beniton
SET B2Dfolder=F:\
SET BEPath="D:\Program Files\Symantec\Backup Exec\bemcmd.exe"
SET Action=ECHO
SET ActionDir=ECHO
IF /I "%1" EQU "/run" SET Action=DEL & SET ActionDir=RD
IF /I "%1" EQU "-run" SET Action=DEL & SET ActionDir=RD
:PREPARE
:: First, some general cleanup to be sure we're starting fresh
IF BEPath=="" Echo "Cannot find the path to BackupExec! Please edit the command script." & goto End
IF EXIST %B2Dfolder%Media.txt DEL %B2Dfolder%Media.txt
IF EXIST %B2Dfolder%Media1.txt DEL %B2Dfolder%Media1.txt
IF EXIST %B2Dfolder%Media2.txt DEL %B2Dfolder%Media2.txt
IF EXIST %B2Dfolder%Dir.txt DEL %B2Dfolder%Dir.txt
IF EXIST %B2Dfolder%%Del%.txt DEL %B2Dfolder%Del.txt
:: You may need to stop the winmgmt service, because at least in some environments, it keeps
:: handles open to files we may be planning to delete. If necessary, uncomment the following
:: (remove the initial "::" from the line).
:: **** Also uncomment it below (in the CLEANUP section) ***
:: NET STOP winmgmt
:MAIN
:: Now we're ready to delete old files (as long as /run was specified,
:: otherwise we'll just display a list)
:: First, dump a list of all the media labels Backup Exec is currently using. If we can't get this,
:: quit with an error.
%BEPath% -o132 -j%MediaSet% >%B2Dfolder%Media1.txt
IF NOT Errorlevel=1 net send %computername% Error getting listing of Backup Exec B2D Media! & GOTO Cleanup
:: Next, extract all the lines showing an actual in-use media (these will be the backup-to-disk file names)
FINDSTR /c:"LABEL: " %B2Dfolder%Media1.txt > %B2Dfolder%Media2.txt
FOR /f "tokens=3 delims= " %%m in (%B2Dfolder%Media2.txt) do ECHO %%m >>%B2Dfolder%%Media.txt
:: Next, list all the files and folders in the Backup-to-Disk directory.
FOR /r %%d in (%B2Dfolder%*.bkf) do ECHO %%~nd >>%B2Dfolder%Dir.txt
FOR /d %%d in (%B2Dfolder%*.) do ECHO %%~nd >>%B2Dfolder%Dir.txt
:: Next, find all lines it the list of files that are NOT (/v) in Backup Exec's
:: list of current media. This gives us a list of files to be deleted.
FINDSTR /v /g:%B2Dfolder%Media.txt %B2Dfolder%Dir.txt > %B2Dfolder%Del.txt
:: Finally, execute the required action against each item listed in our Del.txt file
:: from the previous step. Note again that unless you run this script with the /run
:: command-line parameter, it will not delete files but instead just list them.
CD /D %B2Dfolder%
FOR /F %%i in ('findstr /b IMG %B2Dfolder%Del.txt') do %ActionDir% /s/q %%i
FOR /F %%b in ('findstr /b B2D %B2Dfolder%Del.txt') do %Action% /f/q %%b.bkf
:CLEANUP
:: Clean up after ourselves, like good citizens!
:: NET START winmgmt
ENDLOCAL
IF EXIST %B2Dfolder%Media.txt DEL %B2Dfolder%Media.txt
IF EXIST %B2Dfolder%Media1.txt DEL %B2Dfolder%Media1.txt
IF EXIST %B2Dfolder%Media2.txt DEL %B2Dfolder%Media2.txt
IF EXIST %B2Dfolder%Dir.txt DEL %B2Dfolder%Dir.txt
IF EXIST %B2Dfolder%%Del%.txt DEL %B2Dfolder%Del.txt
POPD
:END
07-08-2009 02:06 AM
07-08-2009 07:29 AM
07-08-2009 08:49 AM
07-08-2009 09:28 AM
07-08-2009 09:40 AM
07-09-2009 12:08 AM
07-09-2009 05:49 AM
09-11-2009 07:35 AM
09-17-2009 06:28 PM
09-18-2009 05:14 AM
09-18-2009 07:49 AM
09-25-2009 03:46 AM
09-25-2009 04:28 AM
11-13-2009 09:30 AM
@Echo Off :: A script to delete BKF files and IMG folders no longer needed by Backup Exec. :: :: Original by Armin Kerl, modifications by Matthew Miller. :: :: If you have comments or questions, please join the forum and post on the thread at: :: https://forums.symantec.com/syment/board/message?board.id=be12_exchange&thread.id=380 :: :: Note that this will run properly only on a machine running Windows 2003 or XP SP2 with :: command extensions turned on (which is the default on those systems). :: :: History :: 2008-08-19 AK Original Version :: 2008-12-31 MM Modified to English, added formatting & comments. :: Changed to run test only unless /run parameter is specified. :: Added recursion through B2D subdirectories (since Backup Exec :: adds \Veritas\B2D to all removable B2D directories on our systems) :CONFIGURE SETLOCAL PUSHD :: :: Change the following 3 items below to match your installation. :: :: * MediaSet - the Backup Exec Media Set Name you're using for backup-to-disk jobs :: (It's best to make this a name without spaces) :: * B2Dfolder - the full path to the backup-to-disk folder you're using for the job :: * BEPath - the full path to the Backup Exec executables (specifically, bemcmd.exe). :: (If you didn't change it, this is C:\Program Files\Symantec\Backup Exec\becmd.exe, :: on US English systems) SET MediaSet=Default SET B2Dfolder=D:\Serv01\ SET BEPath="C:\Program Files\Symantec\Backup Exec\bemcmd.exe" SET Action=ECHO SET ActionDir=ECHO IF /I "%1" EQU "/run" SET Action=DEL & SET ActionDir=RD IF /I "%1" EQU "-run" SET Action=DEL & SET ActionDir=RD :PREPARE :: First, some general cleanup to be sure we're starting fresh IF BEPath=="" Echo "Cannot find the path to BackupExec! Please edit the command script." & goto End IF EXIST %B2Dfolder%Media.txt DEL %B2Dfolder%Media.txt IF EXIST %B2Dfolder%Media1.txt DEL %B2Dfolder%Media1.txt IF EXIST %B2Dfolder%Media2.txt DEL %B2Dfolder%Media2.txt IF EXIST %B2Dfolder%Dir.txt DEL %B2Dfolder%Dir.txt IF EXIST %B2Dfolder%%Del%.txt DEL %B2Dfolder%Del.txt :: You may need to stop the winmgmt service, because at least in some environments, it keeps :: handles open to files we may be planning to delete. If necessary, uncomment the following :: (remove the initial "::" from the line). :: **** Also uncomment it below (in the CLEANUP section) *** :: NET STOP winmgmt :MAIN :: Now we're ready to delete old files (as long as /run was specified, :: otherwise we'll just display a list) :: First, dump a list of all the media labels Backup Exec is currently using. If we can't get this, :: quit with an error. %BEPath% -o132 -j%MediaSet% >%B2Dfolder%Media1.txt IF NOT Errorlevel=1 net send %computername% Error getting listing of Backup Exec B2D Media! & GOTO Cleanup :: Next, extract all the lines showing an actual in-use media (these will be the backup-to-disk file names) FINDSTR /c:"LABEL: " %B2Dfolder%Media1.txt > %B2Dfolder%Media2.txt FOR /f "tokens=3 delims= " %%m in (%B2Dfolder%Media2.txt) do ECHO %%m >>%B2Dfolder%%Media.txt :: Next, list all the files and folders in the Backup-to-Disk directory. FOR %%d in (%B2Dfolder%*.bkf) do ECHO %%~nd >>%B2Dfolder%Dir.txt FOR /d %%d in (%B2Dfolder%*.) do ECHO %%~nd >>%B2Dfolder%Dir.txt :: Next, find all lines it the list of files that are NOT (/v) in Backup Exec's :: list of current media. This gives us a list of files to be deleted. FINDSTR /v /g:%B2Dfolder%Media.txt %B2Dfolder%Dir.txt > %B2Dfolder%Del.txt :: Finally, execute the required action against each item listed in our Del.txt file :: from the previous step. Note again that unless you run this script with the /run :: command-line parameter, it will not delete files but instead just list them. CD /D %B2Dfolder% FOR /F %%i in ('findstr /b IMG %B2Dfolder%Del.txt') do %ActionDir% /s/q %%i FOR /F %%b in ('findstr /b B2D %B2Dfolder%Del.txt') do %Action% /f/q %%b.bkf :CLEANUP :: Clean up after ourselves, like good citizens! :: NET START winmgmt IF EXIST %B2Dfolder%Media.txt DEL %B2Dfolder%Media.txt IF EXIST %B2Dfolder%Media1.txt DEL %B2Dfolder%Media1.txt IF EXIST %B2Dfolder%Media2.txt DEL %B2Dfolder%Media2.txt IF EXIST %B2Dfolder%Dir.txt DEL %B2Dfolder%Dir.txt IF EXIST %B2Dfolder%Del.txt DEL %B2Dfolder%Del.txt ENDLOCAL POPD :END