Comprehensive data protection for all workloads
Post Reply
herbert
Lurker
Posts: 1
Liked: 1 time
Joined: May 08, 2025 3:44 am
Full Name: Herbert
Contact:

Add remark on export backup

Post by herbert » 1 person likes this post

It seems that no remarks can be added to the "Export Backup" function, and the "reason" also does not displayed after the export is completed.

Currently, we can only keep track of the exported copies using a text file, which is inconvenient for an enterprise and multi-admin environment.
david.domask
Veeam Software
Posts: 2833
Liked: 647 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Add remark on export backup

Post by david.domask »

Hi herbert, welcome to the forums.

Your request is noted, I also noticed this could use a bit of love as it's not so straight-forward to track the reason for an export.

The reason actually is stored with the Export Backup session information, so you can review the session data in the History Tab.

As a workaround for now, please consider the following Powershell script, it will retrieve the reason and restore point information for exported backups:

Code: Select all

function Generate-VBRExportedBackupReport {
	$sess = Get-VBRSession -Type VBKExport
	$rSess = Get-VBRRestoreSession -Id $sess.id
	$exportedBackups = Get-VBRBackup | Where-Object {$_.IsExported -eq $true}
	If(-not($exportedBackups)){Write-Host "No exported backups found. Please confirm they exist and try again.";Break}
	$ExportedBackupsReport = @()
	Foreach($r in $rSess){
		$optionsXml = [xml]$r.Info.Options
		$retainDate = $optionsXml.VbkExportSpec.Spec.RetainDate
		$reason = $r.Info.Reason
		$loggerData = $r.Logger.GetLog().GetRecordsSortedByOrdinalId()
		$loggerTitleEntry = ($loggerData| Where-Object {$_.Title -like "*Processing*"}).Title
		$backupExportNameFromLogger = $loggerTitleEntry.Split()[-1]
		$titleWorkspace = ($loggerTitleEntry | Select @{n="Vmname";e={$_.Split()[-2]}}, @{n="SecondName";e={($_.Split()[-1].Split("_")[1,2] -Join "_")}}) #[6]
		$altBackupNameFromLogger = ($titleWorkspace.VMName + "_" + $titleWorkspace.SecondName) #[3]
		$rCreationTime = $r.CreationTime
		$backup = $exportedBackups | Where-Object{$_.Name -eq $backupExportNameFromLogger -and $_.CreationTime -gt $rCreationTime}
		If(-not($backup)){
			$backup = $exportedBackups | Where-Object{$_.Name -eq $altBackupNameFromLogger -and $_.CreationTime -gt $rCreationTime}
			If(-not($backup)){Continue}
		}
		If($backup.Count -gt 1){$backup = $backup | Sort-Object -Property CreationTime | Select -First 1}
		If($backup.id -in $ExportedBackupsReport.BackupID){Continue}
		$origRp = Get-VBRRestorePoint -Id $r.OibId -WarningAction SilentlyContinue
		$data = [PSCustomObject]@{
			ExportSessionId = $r.Id
			MachineName = $r.Name
			ExportSessionStartTime = $rCreationTime
			ReasonForExport = $reason.Trim()
			RetainUntil = $retainDate
			BackupName = $backup.Name
			BackupID = $backup.Id
			BackupCreationTime = $backup.CreationTime
			OriginalRestorePointID = $origRp.id
			OriginalRestorePointName = $origRp.Name
			OriginalRestorePointCreationTime = $origRp.CreationTime
			OriginalRestorePointSourceJob = $origRp.GetBackup().JobName
		}
		$ExportedBackupsReport += $data
		Remove-Variable data
	}
	return $ExportedBackupsReport
}


<#Notes

1. Regrettably we must rely on string validation for this script as there is no direct link between an Export Backup session and the resulting exported backup. An Export Backup session is a CRestoreSession type, so we need to use some logic to decide how to match an ExportVBK session to an Exported Backup. We match on the backup name and the expected name from the ExportVBK session title.
2. We collect all the exported backups in advance - this will pull from Backups > Disk (Exported). Unclear if it will work with Exported backups elsewhere (does not work with Archive Tier Exported Backups)
3. $altBackupNameFromLogger is required due to Note #1; some backup types will have a different Title entry in logger and we need to munge some fields together. See note 6
4. Identifying the $backup has a potential logic flaw -- because of Note #1, we may have a situation where multiple backups from the same restorepoint/machine are exported on the same day. Logically, the backup CreationTime closest to the ExportVBK session CreationTime is the correct one, but it is entirely possible with many exports from the same Restore Point MIGHT result in a wrongly captured backup. Most results should be correct, and included information ought help to ensure it's correct)
5. Remove-Variable was introduced as Powershell would write $data stupidly to the array if there were errors in processing. No idea what caused it, but clearing the variable fresh each iteration helps
6. $titleWorkspace is an absolute mess, I'm sorry. For some hypervisor backups (olvm,proxmox), the export has a different format than VMware and HyperV and Agents. Splitting on a space character for VMware/HyperV/Agents lets you get the Exported Backup display name by calling -1 from the split. For other backups, -2 will be the machine name (restore point machine name) and -1 will be _Backup_YYYY-MM-DD (I might have date order wrong). Display name for the Exported backup in these cases will be machine name_YYYY-MM-DD, so we need to do a little stupid with Split(). On second Split("_"), we do this to drop backup, then just rejoin machine name + date. It's dumb but it matches the naming logic, so let us hope it doesn't change. This is why strings are the devil.

#>
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Semrush [Bot] and 3 guests