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
Comments
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
you are right.
Put it in to a Batch Script (DelMedia.bat), but do not call it by Post Job.
It does not run all Times if it is running as Post Job Command.
I run it by Windows Scheduler at 15:00.
You have to set Your "Overwrite Protection Period" of the MediaPool so, that the Media is Overwriting before the Disk is Full (for example to 1 or 2 Days).
set MediaSet = This is the Name of the Media Set (not the B2D Device Name).
Here is a Updated Version:
(If you fond this :smileywink:, replace it by ) , I dont know why this Editor do this.)
set MediaSet=B2D
set GRTFolder=E:\B2D\
del "%GRTFolder%*.txt"
if not exist "%DSMI_DIR%BemCMD.exe" Echo "Can not find Path to BackupExec!" & goto End
"%DSMI_DIR%BemCMD.exe" -o132 -j%MediaSet% >"%GRTFolder%Media1.txt"
if not errorlevel=1 net send %computername% Error listing BackupExec GRT Media! & goto End
findstr /c:"LABEL: " "%GRTFolder%Media1.txt" >"%GRTFolder%Media2.txt"
for /f "usebackq tokens=3 delims= " %%m in ("%GRTFolder%Media2.txt") do echo %%m >>"%GRTFolder%Media.txt"
for %%d in ("%GRTFolder%*.bkf") do echo %%~nd >>"%GRTFolder%Dir.txt"
for /d %%d in ("%GRTFolder%*.") do echo %%~nd >>"%GRTFolder%Dir.txt"
findstr /v /g:"%GRTFolder%Media.txt" "%GRTFolder%Dir.txt" >"%GRTFolder%Del.txt"
for /f %%i in ('findstr /b IMG "%GRTFolder%Del.txt"') do rd /s/q "%GRTFolder%%%i"
for /f %%b in ('findstr /b B2D "%GRTFolder%Del.txt"') do del /f/q "%GRTFolder%%%b.bkf"
:End
Armin
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
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
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:
Not working...
Hi all,
Sorry to resurect an old post, but I've got a problem with this script.
Ive edited the options to refect my setup, but I get this error.
The script doesn't appear to be creating Meida.txt.
RE: Not working...
Why worry about removing old IMG folders and data
by setting an OPP that meets your need, just let BackupExec reuse them after they are no longer needed?
If this response answers your concern, please mark it as a "solution"
You'll have to forgive me.
You'll have to forgive me. How do i go about that?
RE Setting OPP
edit the properties of the media set your are writing the backup to
If you need to keep the data on disk for two weeks, set the Overwrite Protection to 13 days, for example
But remember, if your job are Append rather than Overwrite, the OPP for all of the BKF files in an "append family" is reset each time a back closes, so NONE of them will ever expire
If this response answers your concern, please mark it as a "solution"
Prior to 12 the IMG folders
Prior to 12 the IMG folders (from GRT) did not pay attention to a retention policy, but now that BE follows the retention policy you should not need the script.
Thanks guys, I will see if
Thanks guys, I will see if that works.
I've just started a new role, having never seen BE before, (fresh out of Universty) Is there a book or some material that I can read to get me up to speed?
Start off by downloading the
Start off by downloading the admin guide and look at a lot of threads here.
The admin guide is around 1200 pages, but I took a couple of days to look through what pertained to my work and went from there. Lurking here helps a lot as you can see a lot of different errors and the related solutions/attempts and solutions.
Prior to 12 comment not true
I am running Backup Exec 12.5 and we are still having to delete the IMG files manually. We will try the script and see how it goes. It looks like it should do the trick.
Maybe I blinked, but I have
Maybe I blinked, but I have never seen a version of Backup Exec 12.5 (SP2 now) which successfully deletes the img folders. It's good to see someone else with the same frustration....
I found this http://support.veritas.com/docs/317211
which reads
"The above mentioned issue is mainly seen in but may not be limited to Windows Small Business Server 2003.
Workarounds:
The expired IMG folder cannot be deleted unless the "WMIPRVSE.EXE" process is stopped. To delete the expired IMG media please follow the steps mentioned below:
Workaround 1
I think the hint is SBS2003. I am using SBS2008 and it also fails.
Thanks for the input re batch files, I will implement them today. Can't wait for Symantec to fix it!!!!!
David
Excellent script!
I had to change it at the lines with net stop/start to include lines for Microsoft Exchange Management.
NET STOP "Microsoft Exchange Management"
NET STOP winmgmt
NET START winmgmt
NET START "Microsoft Exchange Management"
Thanks for the good batch file!
Bengt Nilsson, DATAFANT AB, Sweden
As long as the overwrite is
As long as the overwrite is set correctly you should not have to delete IMG folders.
What will happen is the IMG files will fill up your storage, then start to reclaim space.
If this script works for people, great! You really should look at the overwrite setting though as 12.5 initial release handled GRT backups without issue. The same remains true for it being fully patched 12.5
Overwrite doesn't matter on SBS, it's a bug
I am using 12.5 fully patched on SBS 2003. My overwrite period is 12 hours. There are plenty of alerts that BE is reclaiming space from old IMG folders, and they are removed from the media list, but the folders remain in the file system with a single file, ese.dll. As someone else pointed out, this link http://seer.entsupport.symantec.com/docs/317211.htm is clear confirmation from Symantec that it's a bug.
Document 317211 does not
Document 317211 does not actually acknowledge it is a bug it actually states that another application on the server is responsible for locking a file or files in the folder stopping it from being removed.
The document is also discussing a cause for the folders being left behind - as far as I am aware the bulk of the data contained in the folder should still get removed when the recliam attempt occurs, it is usually just some relatively small files that are locked that causes the folder to be left behind.
Finally the document actually shows a way to detect what is locking the files (by using Process Explorer to check the locks on any files left behind. So if you can see statements in Backup Exec indicating the a reclaim has occured but the folder in the message is still on the system then you should consider using the same utility to identify the cause.
Hi all, I've updated the
Hi all,
I've updated the script slightly as it wasn't quite working for me.
Unfortunately my updates were more dumb luck than skill so if you have a problem don't bother asking me.
Hope this helps someone
Andrew
P.S. I didn't bother updating the version info as the changes were so minor
Would you like to reply?
Login or Register to post your comment.