PowerShell script exchange
Post Reply
ShawnKPERS
Enthusiast
Posts: 61
Liked: 4 times
Joined: Apr 29, 2011 3:55 pm
Full Name: Shawn Nix
Contact:

Using PowerShell to get a backup chain ID if one exists

Post by ShawnKPERS »

I am trying to write a script that can kick off a Veeam backup to tape job that will collect all the related full/incremental backup files for the second to latest backup chain on disk for a given Veeam backup job and copy them to tape.

For example lets say I have a weekly Veeam backup job that backs up multiple VMs to disk and keeps them on disk months. Each Monday a new active full is created and the remaining days of the week each have an incremental backup for that day. Now lets say I have 3 weeks of these backups on disk at the moment. That would mean I have three full backup files, each with six incremental backup files associated to the given full backup giving us 21 files in total.

Now lets say I want to copy just week 2 backup files to tape. In the past I would use a file to tape job and come up with a way to filter down to just the backup files associated to that weeks files that I needed in the GUI. But now on Veeam B&R 12.1, if I did that it would require buying more licenses if the total file size went over a specific limit. So instead I would like to use a Veeam backup to tape job to do the backup and just tell it to copy the second to last backup chain (aka week 2 backup files) to tape.

I am looking around in PowerShell but having issue file an ID on the recovery points of the files that tie all the full/incremental backups for a given backup chain together.
david.domask
Veeam Software
Posts: 2113
Liked: 509 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Using PowerShell to get a backup chain ID if one exists

Post by david.domask »

Hi @ShawnKPERS,
In the past I would use a file to tape job and come up with a way to filter down to just the backup files associated to that weeks files that I needed in the GUI. But now on Veeam B&R 12.1, if I did that it would require buying more licenses
Just to confirm, you're talking about Veeam Backup files, like VBK, VIB, etc?

https://helpcenter.veeam.com/docs/backu ... ml?ver=120

See bullet point 3 here:
When your unstructured data sources are protected with file backup to tape or object storage backup to tape jobs, Veeam backup files are excluded from the instance consumption calculation. These files have the following extensions: VAB, VBM, VBK, VIB, VRB, VSB, VLB, VSM, VLM, VOM, VACM, VASM, VSOURCE, VSOURCETEMP, VSTORE, VSTORETEMP, VSLICE, VBASKET, VLIST, VCACHE, VBLOB, BCO, ADB.
All Veeam backup files are free (as in beer) to copy to tape with File to Tape, so the File to Tape changes won't consume instances. So your strategy should work.

Trying to get Backup to Tape to only grab older points is a bit of an exercise so I don't advise this. Is there a reason not to just put all the chains on tape with a backup to tape job? (my mind imagines tape costs, but maybe there's another reason) You can have both regular backup to tape and file to tape jobs pointing to same media pool and tapes, so even if you do need to do a "one-off" copy to tape, no issues.
David Domask | Product Management: Principal Analyst
ShawnKPERS
Enthusiast
Posts: 61
Liked: 4 times
Joined: Apr 29, 2011 3:55 pm
Full Name: Shawn Nix
Contact:

Re: Using PowerShell to get a backup chain ID if one exists

Post by ShawnKPERS »

Hi @david.domask,
Just to confirm, you're talking about Veeam Backup files, like VBK, VIB, etc?
Yes, I am talking about Veeam specific backup files. I was not aware Veeam files were exempt from the new licensing so that is great news! The script I was writing was only intended to be used in rare situations where our existing Veeam to tape job had failed and was not able to be successfully ran in time before the next backup chain was started. It sounds like that will not be necessary at this point, thank you for pointing that out.

That said, I'm still interested to know if there is an identifier built into the recovery points that allow you to query Veeam and get a list of all registered backup files associated to a specific full backup. Does this identifier exist or similar method to programmatically get this information?
david.domask
Veeam Software
Posts: 2113
Liked: 509 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Using PowerShell to get a backup chain ID if one exists

Post by david.domask »

Glad I could share some good news for you Shawn!

And sure, for your second question, the relationship between Restore Points and Backups is on the BackupID property of COib objects returned by Get-VBRRestorePoint. Normally any time I need to do work with specific restore points, I first get the intended backup with Get-VBRBackup, save it to some variable, then pass that variable on the -Backup flag of Get-VBRRestorePoints.

With True Per Machine backups, this gets a little interesting as each machine in the backup has its own backup chain which means each machine has its own BackupID, and these are united under a Parent Backup ID. Get-VBRBackup will return the Parent Backup, and when you pass this to Get-VBRRestorePoint, it will know how to handle this and return all the child backups from the parent.

Finding the link between a given Full and its increments is also not too hard, but there's a bit of structure to understand. COib objects returned by Get-VBRRestorePoint have a LinkId property; LinkId is used to establish the chain from an increment all the way to the VBK it depends on.

Code: Select all

PS C:\Users\Administrator> $rps | Sort -Property CreationTime -Descending | select id, name, type, linkID

Id                                   Name              Type LinkId
--                                   ----              ---- ------
3d2f5d39-2592-40f1-ac83-3de9131b1ac7 ddom-malware Increment eab9ba0d-2cc1-4bd5-a32a-86e95f05999a
eab9ba0d-2cc1-4bd5-a32a-86e95f05999a ddom-malware Increment 2af79f54-ec2e-4e24-b439-b51ebea41f5e
2af79f54-ec2e-4e24-b439-b51ebea41f5e ddom-malware Increment 893734a6-9600-48af-8529-7a8a66aff3d2
893734a6-9600-48af-8529-7a8a66aff3d2 ddom-malware      Full 00000000-0000-0000-0000-000000000000
c812f5d9-63a5-4bb1-8f05-f25ecd95ea03 ddom-malware Increment 6b64a946-b845-4cb4-b1e3-a92cbc3511b5
6b64a946-b845-4cb4-b1e3-a92cbc3511b5 ddom-malware Increment 9f4a3336-47b4-400d-8368-59dae2d9da45
9f4a3336-47b4-400d-8368-59dae2d9da45 ddom-malware Increment ba38ac99-de86-4899-a966-81e27d08d698
ba38ac99-de86-4899-a966-81e27d08d698 ddom-malware Increment 3972da4a-a2bc-4148-a4a7-4c49842cc1b1
3972da4a-a2bc-4148-a4a7-4c49842cc1b1 ddom-malware Increment 4fb1d57f-b579-4be3-9b86-7f111e25be28
4fb1d57f-b579-4be3-9b86-7f111e25be28 ddom-malware      Full 00000000-0000-0000-0000-000000000000
Here's an example of a simple job I have with 1 VM in it; you can see that each incremental point links to the previous incremental point, all the way to a full point which has a 0'd LinkID. If you have multiple VMs in a job, sort the list first and pass it to Group-Object on the Name property. Then just select out from the group:

Code: Select all

$rpGroup = $rps | Sort -Property CreationTime -Descending | Group-Object -Property Name
$rpGroup.Group | select id, name, type, linkid
Make sense? You can then write some logic to grab the Ids of the restore points you want.
David Domask | Product Management: Principal Analyst
ShawnKPERS
Enthusiast
Posts: 61
Liked: 4 times
Joined: Apr 29, 2011 3:55 pm
Full Name: Shawn Nix
Contact:

Re: Using PowerShell to get a backup chain ID if one exists

Post by ShawnKPERS »

Makes perfect sense, I originally was looking for a single ID that gets assigned to all backups in a chain and glazed over the LinkId when I noticed the ID id not match up across the full and incremental backups. What I didn't notice originally was that one of the incremental backups did match with the Id but when I started look at it again right after my last post and finally noticed the pattern of how each backup is only linked to the prior backup and that you would need to build some logic to walk back the entire chain.

Thank you for the dialed post this helps confirm what I am just now starting to discover! This was very helpful.
david.domask
Veeam Software
Posts: 2113
Liked: 509 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Using PowerShell to get a backup chain ID if one exists

Post by david.domask »

Glad I could share and confirm your research.

Always welcome, good luck scripting!
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests