Nov 10 2011

Delete Backup Exec B2D Files

Published by at 5:42 pm under Backup

Here’s a script that deletes all the Backup Exec B2D files part of a media set. Stick the following script into a .bat file and edit the first 3 settings Mediaset, B2Dfolder and BEPath.
You can run it straight.
 
I consider it is good practice to do for the following reasons:
– You can of course set the overwrite protection and Backup Exec reuses the BKF files when they’re no longer needed. This system works pretty well in most cases especially if there’s plenty of space on the disk. If a backup is delayed and you run out of space, the next backup will be delayed until the first times out.
– I’ve seen enough people on forums getting bad restore or duplication speed due to a high disk fragmentation. This is no more an issue when files get deleted.
 

@Echo Off
::
:: Deletes Backup Exec BKF files.
::

:CONFIGURE
 SETLOCAL
::
:: Edit the following 3 items below to match your installation.
::
:: * MediaSet - the Backup Exec Media Set Name you are using for backup-to-disk jobs 
::   Works with spaces
:: * B2Dfolder - the full path to the backup-to-disk folder you are using for the job
:: * BEPath - the full path to the Backup Exec executables (specifically, bemcmd.exe).
::   (If you did not change it, this is C:\Program Files\Symantec\Backup Exec\bemcmd.exe, 
::   on US English systems)

 SET MediaSet="Disk Media"
 SET B2Dfolder=S:\Backup\
 SET BEPath="C:\Program Files\Symantec\Backup Exec\bemcmd.exe"

 IF NOT EXIST %BEPath% ECHO Cannot find the path to Backup Exec!^
 Please edit the command script. ^
 && goto End

:: Get Media Set Id from Media Set Name
:: Works with white spaces

 FOR /F "tokens=3" %%m IN ('"%BEPath% -o70 -j%MediaSet%" ^| FINDSTR ^{[-0-9A-F]*}
) do (
   SET MediaSetId=%%m
 )

:: Retired Media Set Id: identical on all systems
 SET RetiredMediaSetId={00000009-0002-0000-0000-000000000000}

:MAIN
::
:: First, dump a list of all the media labels Backup Exec is currently using.
:: Move them to the retired media set
:: and deletes them in Backup Exec and physically on the disk
::

 FOR /F "tokens=3" %%m IN ('"%BEPath%" -o132 -i%MediaSetId% ^| FINDSTR ^B2D[0-9]*
) do (
  ECHO Processing %%m...
  :: Move media to Retired Medias
  %BEPath% -o130 -j%%m -ms:%RetiredMediaSetId% > NUL
  :: Delete media from Backup Exec
  %BEPath% -o129 -m%%m > NUL
  :: Delete media from filesystem
  IF EXIST %B2Dfolder%%%m.bkf DEL %B2Dfolder%%%m.bkf
 )

:END
ENDLOCAL

 
Note: The script should be scheduled in the Windows Scheduled Tasks. Don’t launch it from a Backup Exec pre-job script, it will not run. Only a limited number of bemcmd operations can be performed in a pre-job script


5 responses so far

5 Responses to “Delete Backup Exec B2D Files”

  1. Dropbox Driveon 17 Aug 2012 at 7:04 pm

    I am not sure the place you are getting your info, but good topic. I must spend a while learning much more or understanding more. Thanks for fantastic info I used to be looking for this info for my mission.

  2. daveon 25 Sep 2012 at 4:24 pm

    On Backup Exec 2012, backups to disk don’t go into media sets anymore. Data retention is now managed within jobs.
    http://www.symantec.com/business/support/index?page=content&id=DOC5216

    Moreover, BEMCMD has been replaced with BEMCLI which runs with Powershell. BEMCLI module doesn’t provide functions to manage media sets on disk.
    You can vote for it on
    http://www.symantec.com/connect/ideas/bemcli-should-support-backup-set-information

    For these two reasons, deleting B2D files can only be done manually on Backup Exec 2012

  3. disk cleanup for windowson 04 Feb 2013 at 7:46 am

    disk cleanup for windows…

    […]Netexpertise » Delete Backup Exec B2D Files[…]…

  4. kennygon 23 May 2013 at 3:59 pm

    I know this is an old post, but I am just getting into backup exec again…

    I’m confused about this because your script does not differentiate between overwritable files (scratch) and files still under overwrite protection.

    Are you assuming that the media set only contains scratch files?

    Thanks,

    Ken

  5. daveon 27 May 2013 at 9:54 pm

    Files go to the “retired” mediaset, that removes the overwrite protection.
    Check above comment, this only relates up to version 2010, not 2012!

    Dave

Trackback URI | Comments RSS

Leave a Reply