Write latest active full produced .vbk to tape

PowerShell script exchange

Write latest active full produced .vbk to tape

Veeam Logoby michaelryancook » Thu Apr 30, 2015 8:02 pm

Hello all,

I hoping someone has already written a script for this that they could share or it is an easy enough request to create a script for me. I'd like to have a script that will write the latest active full produced .vbk to tape. I would then want to schedule this for the day after my active full is written to disk. As I am using reverse incremental mode with a monthly active full does this seem possible? I guess having a better understanding of the files on disk after the active full would assist in my file selection criteria. If I understand it correctly, directly after the active full would I have the .vbk for that day as part of my reverse incremental chain as well as a second copy of the .vbk that is the active full. Which one is produced first? I am thinking this would help select the active full based on time of creation. If this is not possible then I could simply run the script one day later where the active full is guaranteed to be the second newest .vbk.

Also if I went this route would Veeam B&R still be aware of the individual VMs that are backed up to tape allowing the expansion of the backups on tape section to show the individual VMs or would it then only expand to show the .vbk?

Any help would be greatly appreciated.
michaelryancook
Expert
 
Posts: 113
Liked: 14 times
Joined: Tue Nov 26, 2013 6:13 pm
Full Name: Michael Cook

Re: Write latest active full produced .vbk to tape

Veeam Logoby michaelryancook » Thu Apr 30, 2015 8:29 pm

I have this so far which selects the second most recent .vbk which if run two days after the active full would be the .vbk produced by the active full. I am going to try to use this as the selection for the tape job.

Code: Select all
Add-PSSnapin VeeamPSSnapin

$ProdBackupDir = "D:\Backup\Prod Backup Job\"

$ProdBackupDirVbks = dir $ProdBackupDir -Filter "*.vbk"
$SecondLatestVbk = $ProdBackupDirVbks | group directory | foreach {@($_.group | sort {[datetime]$_.creationtime} -desc)[1]}

$FilePath = $SecondLatestVbk.DirectoryName
$FileName = $SecondLatestVbk.Name

Write-Host $FileName
michaelryancook
Expert
 
Posts: 113
Liked: 14 times
Joined: Tue Nov 26, 2013 6:13 pm
Full Name: Michael Cook

Re: Write latest active full produced .vbk to tape

Veeam Logoby michaelryancook » Thu Apr 30, 2015 8:30 pm

My selection code was derived from this post: post125443.html?hilit=latest%20vbk%20to%20tape#p125443
michaelryancook
Expert
 
Posts: 113
Liked: 14 times
Joined: Tue Nov 26, 2013 6:13 pm
Full Name: Michael Cook

Re: Write latest active full produced .vbk to tape

Veeam Logoby michaelryancook » Thu Apr 30, 2015 8:49 pm

I believe what I have below will work. Can anyone please confirm or advise if there is an easier way of accomplishing this?

Code: Select all
Add-PSSnapin VeeamPSSnapin

$ProdBackupDir = "D:\Backup\Prod Backup Job\"

$ProdBackupDirVbks = dir $ProdBackupDir -Filter "*.vbk"
$SecondLatestVbk = $ProdBackupDirVbks | group directory | foreach {@($_.group | sort {[datetime]$_.creationtime} -desc)[1]}

$FilePath = $SecondLatestVbk.DirectoryName
$FileName = $SecondLatestVbk.Name
$VBRFilePath = $FilePath + "\" + $FileName

Write-Host $FileName
Write-Host $VBRFilePath

$ActiveFullObject = New-VBRFileToTapeObject -Path $VBRFilePath

Set-VBRFileToTapeJob -Job LatestProdVBK -Object $ActiveFullObject

Start-VBRJob LatestProdVBK
michaelryancook
Expert
 
Posts: 113
Liked: 14 times
Joined: Tue Nov 26, 2013 6:13 pm
Full Name: Michael Cook

Re: Write latest active full produced .vbk to tape

Veeam Logoby michaelryancook » Thu Apr 30, 2015 9:54 pm

I have now removed the write-host lines, as they were only for my testing of variables, as well as the start-vbrjob line. I have then added this as a pre-job script so that it modifies the file selected right before the file to tape job.
michaelryancook
Expert
 
Posts: 113
Liked: 14 times
Joined: Tue Nov 26, 2013 6:13 pm
Full Name: Michael Cook

Re: Write latest active full produced .vbk to tape

Veeam Logoby michaelryancook » Mon May 04, 2015 4:57 pm

So the VBRFileToTapeJob works but Veeam is not aware that the individual VMs were backed up using this method which would make restoration very dependent on constant documentation of jobs. In case any has been following this thread I changed it to the script below in hopes that recreating the job will cause the backup job to only write the latest to tape.

Code: Select all
Add-PSSnapin VeeamPSSnapin
$JobName = "Prod Backup to Tape Job"
$JobDesc = "Prod Tape Job created by Script"
$BackupObject = Get-VBRJob -Name "Prod Backup Job"
$MediaPool = "Prod"
$MonthlyOptions = New-VBRMonthlyOptions -Period 23:59 -DayNumberInMonth Third -DayOfWeek Sunday
$ScheduleOptions = New-VBRBackupToTapeScheduleOptions -Type Monthly -MonthlyOptions $MonthlyOptions -Enabled

Remove-VBRJob -Job $JobName
Add-VBRBackupToTapeJob -Name $JobName -Description $JobDesc -EjectCurrentMedium -FullBackupMediaPool Prod -WaitForBackupJob -WaitPeriod 776 -ScheduleOptions $ScheduleOptions -Object $BackupObject -ProcessIncrementalBackup:$false
michaelryancook
Expert
 
Posts: 113
Liked: 14 times
Joined: Tue Nov 26, 2013 6:13 pm
Full Name: Michael Cook

Re: Write latest active full produced .vbk to tape

Veeam Logoby michaelryancook » Mon May 04, 2015 5:20 pm

No luck. It processes both my last active full and the most recent reverse incremental produced .vbk. I can't find the option to only process the most recent for a new tape job.
michaelryancook
Expert
 
Posts: 113
Liked: 14 times
Joined: Tue Nov 26, 2013 6:13 pm
Full Name: Michael Cook

Re: Write latest active full produced .vbk to tape

Veeam Logoby v.Eremin » Wed May 06, 2015 2:19 pm

Yep, the re-creation of a backup to tape job wouldn't make a job copy only the latest .vbk file. The options you have are combination of files to tape job and scripting and forward forever mode with virtual synthesized full backup.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 969 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Write latest active full produced .vbk to tape

Veeam Logoby remko.de.koning » Fri May 08, 2015 2:16 pm

Hi, I would like to jump in as well if that's ok?

I have to say that I am completely new to scripting with Veeam but I think that my goal is the same as the the topic starter. I wasn't able to find my answer in the GUI of B&R so perhaps powershell has an answer to my problem.
I have reversed incrementals and one real full each month. I want to put one full to tape each month. It doesn't really matter which one. Right now it puts both full's on tape which consumes my tapes twice as fast.
What can I do to put only one full on tape?
My retention period on disk is one month so each month contains two full's. One real and one synthetic.
remko.de.koning
Enthusiast
 
Posts: 72
Liked: 13 times
Joined: Wed May 21, 2014 12:15 pm
Full Name: Remko de Koning

Re: Write latest active full produced .vbk to tape

Veeam Logoby michaelryancook » Fri May 08, 2015 2:21 pm

Something that has worked for me but is clunky is simply putting in enough tapes for one of the .vbk and then cancelling the tape job once it finishes sending the first .vbk to tape. This way if I run it at least one day after the active full I end up with the tape job showing as failing but I have the active full on tape and Veeam is aware of which VMs are protected on tape.
michaelryancook
Expert
 
Posts: 113
Liked: 14 times
Joined: Tue Nov 26, 2013 6:13 pm
Full Name: Michael Cook

Re: Write latest active full produced .vbk to tape

Veeam Logoby v.Eremin » Fri May 08, 2015 2:53 pm

What can I do to put only one full on tape?

Add a file to tape job, create a script that checks corresponding backup folder, find the latest .vbk, and sets it as a source for the said job. Then, schedule this script using Windows Task Scheduler to take place once a month. Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 969 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Write latest active full produced .vbk to tape

Veeam Logoby remko.de.koning » Fri May 08, 2015 3:18 pm

Are there any examples available? As said, I am new to this and have zero experience with the scripting of Veeam. What would be a good place to start getting familiar with this?
Good to see this problem can be solved.
remko.de.koning
Enthusiast
 
Posts: 72
Liked: 13 times
Joined: Wed May 21, 2014 12:15 pm
Full Name: Remko de Koning

Re: Write latest active full produced .vbk to tape

Veeam Logoby v.Eremin » Fri May 08, 2015 3:26 pm

Have you already tried an example provided by Michael (several posts above); as mentioned there, you can even set the script as pre-job activity, so that, the job is modified before taking place. Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 969 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Write latest active full produced .vbk to tape

Veeam Logoby michaelryancook » Fri May 08, 2015 5:23 pm

Based on the example Vladimir is referring to (second post in this thread) you can choose the latest or second latest backup by modifying "$SecondLatestVbk". If you change the end of that line to [0] you should get the latest .vbk. Whereas [1] gives you the second latest.
michaelryancook
Expert
 
Posts: 113
Liked: 14 times
Joined: Tue Nov 26, 2013 6:13 pm
Full Name: Michael Cook

Re: Write latest active full produced .vbk to tape

Veeam Logoby tsightler » Fri May 08, 2015 11:11 pm

I have a script that does this but it was created specifically for a customer so I need to scrub it and make it a little more generic before I can post it here. I'll try to do that in the next few days.
tsightler
Veeam Software
 
Posts: 4768
Liked: 1737 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Next

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 6 guests