PowerShell script exchange
Post Reply
tomas.olsen
Veeam ProPartner
Posts: 64
Liked: 9 times
Joined: Apr 26, 2011 10:18 pm
Full Name: Tomas Olsen
Contact:

Create Backup Copy Job with Powershell

Post by tomas.olsen »

Hello everyone,
I have a question about creating copy jobs with powershell.
My environment is as follows:

about 200 TB to backup. all vms running on EMC VNX2 FC Storage on VMware vSphere.
I have a physical proxy server with 250TB usable capacity and 2x14 core cpu's and two 10Gbit Ethernet ports. configured with FC so it can do SAN backup over FC.
I have created 50 backup jobs using reversed incremental and 30 restorepoints to local disk of my proxy.
I also have a Datadomain DD2500 with two extra shelves including DDBoost license with OS 5.7.3. with 2x10Gbit Ethernet ports.

I want to make copy jobs of all backup jobs, using GFS for long time retention. since I have a dedup box that is very good at this job, I want to use synthetic full of all copy jobs. This will give me somewhat faster restore times as well. I have created a powershell script for this task, but I am not sure if it will work as intended.
To start with, I want the copy job to run every sunday, so I can copy my Sunday backup as synthetic full to my Datadomain.
Then I want to keep 4 weekly synthetic fulls, and 6 monthly synthetic fulls. I will later increase the monthly to 24, or perhaps higher.
I also want the copy job to run only from midnight to 0800 the next morning. And the backups run from 5pm to 22pm every day.

Here it is:

Code: Select all

#Add-PSSnapin VeeamPSSnapIn
#Getting Datadomain Boost backup repo
$copyrepo = Get-VBRBackupRepository -Name KKBoost*

#GFS Weekly restorepoints
$gfsw_points = 4

#GFS Monthly restorepoints
$gfsm_points = 6

#Total amount of copy restorepoints
$r_points = $gfsw_points + $gfsm_points

#Backup copy window
$t_window = "0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1"

Get-VBRJob -Name Backup-* | select Name | ConvertTo-Csv -NoTypeInformation | Out-File -FilePath c:\scripts\jobs.txt

$data = Import-Csv "c:\scripts\jobs.txt"
$data | % {
    $job = $_.Name
    $copyjobname = "Copy-" + $job
    Add-VBRViBackupCopyJob -BackupJob $job -DirectOperation -Name $copyjobname -Repository $copyrepo
    $joboptions = Get-VBRJobOptions -Job $copyjobname
    $joboptions.GenerationPolicy.SimpleRetentionRestorePoints = $r_points
    $joboptions.GenerationPolicy.KeepGfsBackup = $true
    $joboptions.GenerationPolicy.GFSWeeklyBackups = $gfsw_points
    $joboptions.GenerationPolicy.GFSMonthlyBackups = $gfsm_points
    $joboptions.GenerationPolicy.RetentionPolicyType = "GFS"
    $joboptions.GenerationPolicy.RecoveryPointObjectiveValue = 7
    $copyjobname | Set-VBRJobOptions -Options $joboptions
    $Options = $_.Options
    $Options.JobOptions.BackupCopyJobCanRunAnyTime = $false
    $_.SetOptions($Options)
    $ScheduleOptions = $_.ScheduleOptions
    $ScheduleOptions.OptionsContinuous.Schedule = "<scheduler><Sunday>$t_window</Sunday><Monday>$t_window</Monday><Tuesday>$t_window</Tuesday><Wednesday>$t_window</Wednesday><Thursday>$t_window</Thursday><Friday>$t_window</Friday><Saturday>$t_window</Saturday></scheduler>"
    Set-VBRJobScheduleOptions -Job $_ -Options $ScheduleOptions | Out-Null
    Enable-VBRJob -Job $copyjobname
    } 
This script is a work in progress, so please don't kill me.
The script works fine, but I am not sure if the GFS retention will work as intended, and I am also not sure if I will have full synthetic for all copy restore points.
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests