PowerShell script exchange
Post Reply
nunciate
Veteran
Posts: 257
Liked: 40 times
Joined: May 21, 2013 9:08 pm
Full Name: Alan Wells
Contact:

Create GFS Tape job with Powershell

Post by nunciate »

OK Gurus I am not PowerShell expert and need some help creating a bunch of new Tape Jobs which will utilize a new GFS Media Pool.
Now that GFS Media pools support daily incremental tapes I would love to migrate all my tape jobs over
Most jobs will backup using the regular VM backup job as the object but a few might have multiple backup jobs as their source.

I am trying create this with PowerShell but for some reason I am getting errors and to be honest I am not sure how to format the command to get all the settings I need.

What I want is a single command that will create the following. I don't want to pass a bunch of variables and such. Just one line that I can change information in for each job would be fine.
If that can't be done then using variables would be OK. Perhaps there is an easier way by using PowerShell to simply copy a job and then set new properties?

It would need to create a new job with a given name and description. Use a GFS Media pool of a given name. I would need to add the backup job itself as the source object and also need to know the format to add multiple source jobs here. Also, have it set the Media pool to a given name.

Options would be no check mark on Eject media upon completion and Export media sets. Advanced options should be defaults. The Perform GFS scan daily can also be default at 12:00AM.

On the timing schedule I would set Weekly Full on Thursdays, Monthly Full First Thursday of the Month, Yearly Full set to Day of year April 4th. No Quarterly backup as it is disabled on the media pool.
Lastly on the schedule tab I have checked the option to prevent this job from being interrupted by source backup jobs.

Thanks in advance for any assistance.
nunciate
Veteran
Posts: 257
Liked: 40 times
Joined: May 21, 2013 9:08 pm
Full Name: Alan Wells
Contact:

Re: Create GFS Tape job with Powershell

Post by nunciate »

Alright I got it working with one exception which I am still researching.

With Variables:

Code: Select all

$job = Get-VBRJob -Name "Test Backup Job"
$GFSSchedule = New-VBRTapeGFSScheduleOptions -WeeklyDay Thursday -MonthlyDayOfWeek Thursday -YearlyKind DayOfYear -MonthOfYear April -YearlyDayOfMonth 4
Add-VBRBackupToTapeJob -Name "Test GFS Tape Job" -Description "Test GFS Tape Job" -GFSMediaPool "TX - Dev - Primary GFS Media Pool" -GFSScheduleOptions $GFSSchedule -Object $job
Looks like easiest way to do this for 100+ new jobs is to create a function to iterate through a csv file for the Backup and Tape job names.
Never done that before either so back to researching.

Also, it doesn't appear there is a way to set the option to prevent this job from being interrupted by source backup jobs. I see it nowhere in the powershell guide so I'll have to update that manually on each job.
nunciate
Veteran
Posts: 257
Liked: 40 times
Joined: May 21, 2013 9:08 pm
Full Name: Alan Wells
Contact:

Re: Create GFS Tape job with Powershell

Post by nunciate »

I spent the entire day trying to figure this out and this is what I came up with. If anyone knows how to turn on the last option to prevent this job from being interrupted by source backup jobs that would be helpful otherwise use this. This will iterate through a .csv file with 2 columns containing Tape Job names and Backup Jobs that are sources. It also disables the new jobs after they are created so you can verify them before they try to run. You could probably put other things in your csv if you want to change the days of the full backups for each job. I'll be doing that as I do full backups over several days.

Code: Select all

Add-PSSnapin -Name VeeamPSSnapIn
$gfsmediapool = "Your GFS Media Pool Name"
$GFSSchedule = New-VBRTapeGFSScheduleOptions -WeeklyDay Thursday -MonthlyDayOfWeek Thursday -YearlyKind DayOfYear -MonthOfYear April -YearlyDayOfMonth 4
foreach ($jobnames in (import-csv "$env:USERPROFILE\desktop\info.csv")) {
    $tapejob = $jobnames.TapeJob
    $backupjob = $jobnames.BackupJob
    $job = Get-VBRJob -Name $backupjob
foreach($backupjob in $tapejob){
        Add-VBRBackupToTapeJob -Name $tapejob -Description $tapejob -GFSMediaPool $gfsmediapool -GFSScheduleOptions $GFSSchedule -Object $job
        Disable-VBRJob -Job $tapejob
    }
}
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Create GFS Tape job with Powershell

Post by veremin »

If anyone knows how to turn on the last option to prevent this job from being interrupted by source backup jobs that would be helpful otherwise use this.
It doesn't exist, if I recall correctly.

Anyway, I will double check tomorrow, once I have console at hand, and update the topic.

Thanks!
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 11 guests