Backup & Recovery

The new command-line interface to BE 2012 is based on Powershell which is a rich scripting language.  It has the ability to pass objects from one cmdlet to another.  This ability can speed up some tasks.  BEMCLI is also easier to use than its predesessor, BEMCMD.  The purpose of the cmdlets are quite evident in their names.  This is unlike BEMCMD which uses numbered switches to perform different tasks.

In this article, I will show you some situations which are easily handled by BEMCLI.  However, these are not exhaustive, there are many more circumstances where BEMCLI may be more helpful than the GUI. To distinguish the BEMCLI cmdlets, I will bold them.

You might want to read this article first

Starting Missed Jobs

There are more jobs to managed in BE 2012.  It may be easier to manage them using BEMCLI rather than the GUI.

From the BEMCLI console, you can get all the job history by issuing


You would get

Name                          JobStatus              JobType              StartTime             EndTime

--------                          ----------------             -----------               ----------------            -------------

Backup1                      Succeeded            Backup               4/3/2012 ...           4/5/2012 ...

Backup1                      Missed                  Backup               4/3/2012 ...           4/5/2012 ...


You can filter for jobs starting after a certain date

Get-BEJobHistory | Where-Object {($_.StartTime -ge "4/2/2012")}

or missed backup jobs after a certain date.

Get-BEJobHistory | Where-Object {($_.StartTime -ge "4/2/2012") -and ($_.JobType -eq "Backup") -and ($_.JobStatus -eq "Missed")}

This list of missed jobs can be fed into another BEMCLI cmdlet to start them

Get-BEJobHistory | Where-Object {($_.StartTime -ge "4/2/2012") -and ($_.JobType -eq "Backup") -and ($_.JobStatus -eq "Missed")} | | Foreach-Object {Get-BEJob -name $ | Start-BEJob}

When you issue the above command, for each missed backup job, you would be prompted whether you want to start it.  If you are sure that you want to start all the missed jobs, then you can issue this command.

Get-BEJobHistory | Where-Object {($_.StartTime -ge "4/2/2012") -and ($_.JobType -eq "Backup") -and ($_.JobStatus -eq "Missed")} | | % {Get-BEJob -name $ | Start-BEJob -Conifrm:$false}

(The '%' sign in the command above stands for Foreach-Object.)

There will be no confirmation prompts and all the missed backup jobs will be started.

You can keep the command in a text file and then paste it into the console, or save it as a script and run it.  In either case, a single command can do the job of restarting missed job without the tedious navigation of the GUI.

Clearing Alerts

Let's say you want to look at all the alerts warning you about missed job.  You can issue this cmdlet

Get-BEAlert | Where-Object {($_.Severity -eq "Warning") -and ($_.Category -eq "JobWarning")}

If you are happy with the list and wants to clear them, you can use this command.

Get-BEAlert | Where-Object {($_.Severity -eq "Warning") -and ($_.Category -eq "JobWarning")} | Clear-BEAlert -response ok

You will get a prompt asking you to confirm that you want to clear each prompt.  If you will want to clear all the alerts without any further prompting, you can add the -Confirm:$false parameter to the Clear-BEAlert cmdlet to turn off the promprts

Deleting Media

Suppose you want to delete a tape from BE.  If you use the GUI, then you would need to associate it with the retired media set before you can delete it.  With BEMCLI, you do it with one command, e.g.

Get-BEMedia -name "000001L4" | Remove-BEMedia -Force

The -Force parameter will delete the media even if it is not in the Retired Media set.  This is certainly faster than using the GUI.

Importing Tapes Into The First Empty Slot

BEMCLI can be used to find the first empty slot in your tape library, import a tape into that slot and then clear the media intervention alert from the import job.  See my download below

Unlocking Tape Library

There is no facility in BE 2012 to schedule a job to unlock your tape library.  However, you can schedule this command using the Windows scheduler or use it as a post-command in one of your jobs.

c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe Submit-BEUnlockJob -RoboticLibraryDevice '"Robotic library 0001"'

Note that "Robotic library 0001" is just an example.  You should get the name of your tape library by issuing this cmdlet


Scheduling Utility Jobs

Similar to scheduling a library unlock job, you can also schedule BEMCLI cmdlets to scan your library, do an inventory or catalog your media.

Searching Your Media

You can use the BEMCLI cmdlet, Search-BECatalog, to search your catalog for a particular file/folder.  From the result, you would be able to see roughly which backup sets have this file/folder.

Setting Barcode Rules

If you need to set barcode rules for your tape drives, then you would need BEMCLI.  There is no facility to set barcode rules in the BE 2012 GUI. 


I am sure that there are many more uses for BEMCLI.  It is up to your imagination.  To get a list of BEMCLI cmdlets and their functions, open the BEMCLI_en.chm file in your BE installation directory.  I have also attached it here for convenience.


Does BEMCLI require that I be logged into my BE 2012 Media Server in order to use the commands? If not, how can I specify the BE Media Server to BEMCLI?


Hi David,

BEMCLI can be accessed remotely using PowerShell's built-in remoting infrastructure.  Don Jones, an expert powershell book author and trainer, just published a totally free ebook on PowerShell remoting at -- it's very thorough and goes step-by-step on setting up PowerShell remoting in a wide variety of situations.

One caveat I've found in testing: by default, PowerShell sets up remote sessions with 150MB of memory...if they go over that limit, cmdlets fail with an OutOfMemoryException.  Raising the memory allowed per remote session fixes this -- a reasonable value varies by what you're doing, of course, but I just set mine to something large like 1024 or even 2048MB.

You set the limit via the WSMan: drive on the computer you'll be remoting TO (i.e. where Backup Exec is installed):

   Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB -Value 2048

Beyond that tweak, I refer you to Don Jones' excellent ebook to get everything securely connected for PSRemoting.  If you're in a domain, and using a domain admin account, it's quite easy and straightforward.  It's possible in other scenarios, but requires more tinkering.

-Kirk out


Kirk -


Thanks for that approach, I've got a number of Don's writings, but had not seen the 2 most recent.  I'll be doing some reading this weekend...


Also, thanks for the heads up on the OutOfMemoryException, I'm sure that will reduce my frustrations.


I tried with the first example but I get the following error message for each entry in the job history:
Bad argument to operator '-ge': Could not compare "29/01/2013 12:37:40 p.m." to "28/01/2012". Error: "Cannot convert value "28/01/2012" to
 type "System.DateTime". Error: "String was not recognized as a valid DateTime."".
At line:1 char:51
+ Get-BEJobHistory | Where-Object {($_.starttime -ge <<<<  "28/01/2012")}
    + CategoryInfo          : InvalidOperation: (Smiley Happy [], RuntimeException
    + FullyQualifiedErrorId : BadOperatorArgument

This was my input:

PS C:\scripts> Get-BEJobHistory | Where-Object {($_.starttime -ge "28/01/2012")}


What I noted is that "startime" doesn't autocomplete when i press "tab", is it ok anyways?


suggestions, ideas?


Thanks in advance.

Well, I did my homework and instead of using 

Get-BEJobHistory | Where-Object {($_.StartTime -ge "4/2/2012")}

I learned a little more about this and I'm using this now to check the status of my backups of yesterday, instead of going through the console.

get-bejobhistory -jobtype backup, duplicate | where-object {($_.startime -gt (get-date).adddays(-1))}

If I wanted to check two days ago I just 

get-bejobhistory -jobtype backup, duplicate | where-object {($_.startime -gt (get-date).adddays(-2))}


For 10 days ago:

get-bejobhistory -jobtype backup, duplicate | where-object {($_.startime -gt (get-date).adddays(-10))}


And so...