Skip to main content

List Source Region/Subscription Information for Restore Points from External Repo Backup Copies

  • December 16, 2022
  • 1 comment
  • 38 views

Forum|alt.badge.img+3
  • Comes here often
  • 106 comments

So, this is definitely a deep edge case if you could not tell from the title, if you could even figure out the situation from the title :)

But since I went down this rabbit hole for a case, figured I’d share it for people getting deep into automation and the Veeam Public Cloud Backups who are following 3-2-1 rule and making Backup Copies of these from their External Repositories. Even if you never need to solve this particular use case, I suppose it’s a good example of what you can actually learn about a backup and how to properly parse data without nasty string munging.

Issue: Backup Copies sourced from External Backups don’t have a UI field to associate the Restore Points with the original backed up machine’s public cloud information like Subscription, Region, etc.

Where this likely becomes an issue is when you heavily automate regional deployments and may have identical infrastructures set up uniquely for individual regions. (e.g., you deploy machines with same names for regions that only serve those regions)

This makes it difficult to associate specific machines to specific regions for restores from Backup Copies, and it makes automation even more difficult at first glance.

Solution: The good news is that this information actually is stored in COib objects (RestorePoints) in the AuxData property. So we don’t even need to go into unsupported territory, we just need to do a bit of JSON parsing in Powershell. The following function will produce human readable output for finding the Restore Point ID (for automated restores), Restore Point Creation Time, Region, etc.

 

function Get-ExternalCopyBackupAndRegionInfo{
	param(
		[Veeam.Backup.Core.CBackup[]]$backup,
		[string]$VMName
		)
	$RestorePoint = Get-VBRRestorepoint -Backup $backup
	$RPsToCheck = $RestorePoint | Where-Object {$_.Name -eq $VMName}
	$BackupInfo = @()
	Foreach($r in $RPsToCheck){
		$AuxData = [xml]$r.Info.AuxData
		$JSON1 = ConvertFrom-JSON $AuxData.COibAuxData.OibAuxDataLinuxBackup.PlatformSpecificData.VmbAuxData.InstanceMetadata.UserData
		$JSON2 = ConvertFrom-JSON ($JSON1.Content)
		$JSON3 = ConvertFrom-JSON $JSON2.configFilesMetaData.content[0]
		$BackupInfoEntry = [PSCustomObject]@{
			VMName = $VMName
			RestorePointID = $r.id
			RestorePointDate = $r.CreationTime
			VMRegion = $JSON3.VirtualMachine.RegionName
			VMSubScriptionName = $JSON3.VirtualMachine.ResourceGroup.Name
			VMSubScriptionResourceID = $JSON3.VirtualMachine.ResourceGroup.ResourceID
		}
		$BackupInfo += $BackupInfoEntry
	}
	return $BackupInfo
}

How to use: The function accepts two parameters, -backup, which expects a CBackup object found with Get-VBRBackup, and -VMName, which you can just enter by hand or populate from some CSV.

The output can be seen on the BackupInfoEntry PSCustomObject.

 

Again, I’m positive this is a huge edge case, but for power users on the public cloud who are automating regional deployments and following 3-2-1, probably this will save a lot of time in developing restore automation for the same environments.

Else just see this as an example of cool things you can see in properties.

1 comment

Chris.Childerhose
Forum|alt.badge.img+21
  • Veeam Legend, Veeam Vanguard
  • 8395 comments
  • December 16, 2022

This is a great script.  Thanks for sharing it.


Comment