Video Screencast Help

Switching data storage location with powershell.

Created: 04 Dec 2012 • Updated: 28 Jan 2013 | 3 comments
This issue has been solved. See solution.

Could anyone assist me with getting a script to switch the storage locations of my Backup exec 2012 jobs. I would like to have a script that will get all jobs that are currently being stored to "disk 1" or "disk 2" and change them so they now use the new "storage pool" which includes the two old disks and a third.

 

Thanks in advance.

Comments 3 CommentsJump to latest comment

pkh's picture

You can use the BEMCLI cmdlet Set-BEBackupDefinition to do the change that you want.

Watson's picture

I looked at the Set-BEBackupDefinition paramaters, but I did not see which one I would use to set the storage location.  I also tried using "Get-BEBackupDefinition | format-list *" and did not see anything for storage location. Could you elaborate on how to use the Set-BEBackupDefinition cmdlet to change the storage location?

The only command I could see to list the storage location was Get-BEJob. I ran "get-BEjob | Where-Object {$_.storage -eq "Disk 1" -or $_.storage -eq "Disk 2"}" and it returned a list of the jobs I wanted to change.

Thanks

BE_KirkFreiheit's picture

Hi Watson and pkh,

I am the primary developer of BEMCLI, and am actively implementing our next release.  Please let me know about any features and scenarios that are not intuitive (or fully supported).

You're on the right track -- you need to use the Set-BE*Task cmdlets to change properties of the subtasks within a BEBackupDefinition.

I created the following script to accomplish what you're looking to do.  Ideally, we would provide a cmdlet that allowed you to retarget jobs directly -- for the time being, the following script should help.

One limitation: this will not work with BEOneTimeBackup jobs.  We chose to supply only the Submit-BEOneTimeBackupJob cmdlet for BE 2012, which always makes a new job.  Stay tuned for improvements on that front.  Since you're looking for this functionality on Set-BEBackupDefinition, I think that limitation won't apply to your situation.

BEJobs have properties to let you know if they come from a BackupDefinition or not, and also what their TaskType and TaskName are.  We need all of that info to filter the Get-BEJobs -- and to use as parameters to the "Set-BE*Task" cmdlets (Full, Incremental, Differential, Duplicate).

After each task is altered, you do need to call Save-BEBackupDefinition to commit the change.

Good luck -- please let me know if this solves your needs.
 

# Retarget-BackupDefinitionJobs.ps1

param([string]$currentStorage, [string]$newStorage)

Get-BEJob | ?{$_.Storage.Name -like $currentStorage -and $_.IsBackupDefinitionJob} | %{

$job = $_

$bd = $job.BackupDefinition

 

switch ($job.TaskType) {

"Full" { $bd | Set-BEFullBackupTask $job.TaskName -Storage $newStorage | Save-BEBackupDefinition -Confirm:$false}

"Incremental" { $bd | Set-BEIncrementalBackupTask $job.TaskName -Storage $newStorage | Save-BEBackupDefinition -Confirm:$false}

"Differential" { $bd | Set-BEDifferentialBackupTask $job.TaskName -Storage $newStorage | Save-BEBackupDefinition -Confirm:$false}

"Duplicate" { $bd | Set-BEDuplicateStageBackupTask $job.TaskName -Storage $newStorage | Save-BEBackupDefinition -Confirm:$false}

}

}

 

SOLUTION