Switching data storage location with powershell.
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.
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}
}
}