PowerShell script exchange
Post Reply
David_S
Novice
Posts: 3
Liked: never
Joined: Jan 21, 2020 1:56 pm
Full Name: David Sjöstrand
Contact:

Reference to the files created with export-vbrrestorepoint

Post by David_S »

I want to automate the process of exporting restore points and then movig away the resulting files.
The problem is that export-vbrrestorepoint doesn't seem to return a reference that can be used to locate the actual backup/files.
Export-vbrRestorePoint returns a Veeam.Backup.PowerShell.Infos.VBRSession that contains an Id that can be used with get-vbrrestoresession to find a Veeam.Backup.Core.CRestoreSession. This object, however, does not seem to reference the Veeam.Backup.Core.CBackup or the files created in any way. The name is somewhat predictable, but I would really like to have an unambiguous way to find the exported files.
Mildur
Product Manager
Posts: 8735
Liked: 2296 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Reference to the files created with export-vbrrestorepoint

Post by Mildur »

Hi David

May I know the use case?
You could also use a backup copy job. That would also allow you to automatically "moving away a backup file".
And you can monitor it in the console.

But yes, it would make sense to output the exported path so the backup can be reused for a second command.
I'll try it out myself in the lab.

Thanks
Fabian
Product Management Analyst @ Veeam Software
david.domask
Veeam Software
Posts: 1226
Liked: 323 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Reference to the files created with export-vbrrestorepoint

Post by david.domask »

For a normal repository, you can use the Repository Path/Dirpath/etc to get the full string for the path. But for Scale-out Repository, you need to do some fanciness :(

post443044.html#p443044

I've written this function in the past and you can pass the $ExportedBackup variable and adjust the output to just give you the $PATH result and then pass that to your copy utility.

Here's an example output:

Code: Select all

PS C:\Users\Administrator\Downloads> Get-StoragesPathsAndBlocksizeFromBackup-v11 -Backup $Exportedbackups[0]

Extent       Path                                                                            BlockSize CreationTime
------       ----                                                                            --------- ------------
perf-tier-bb C:\perf-tier-bb\ddom-tinyvm_2022-10-28_1\ddom-tinyvmD2022-10-27T220038_BF53.vbk      4096 10/27/2022 10...
Sorry it's a lot of work, but right now I'm not sure there's a better way.

+1 that it returns the path at that time, but as you can see with Scale-outs, because the paths are relative, that might be tricky.

#MOD: Oleg F. found a better way; removed inefficient/unnecessary method. Use the below to get the file path
David Domask | Product Management: Principal Analyst
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Reference to the files created with export-vbrrestorepoint

Post by oleg.feoktistov » 1 person likes this post

Hi @David_S

Yes, I think it can be solved by adding session reference in a restore point object.
Noted.

Actually, looks like there is a way to know what backup you exported more or less precisely.
Turns out upon export new backup holds the id of the backup it was exported from in OriginalId property.
Then, using some tweaks and going with naming rules for exported backups we can get this:

Code: Select all

$backup = Get-VBRBackup -Name 'Backup Job'
$rps = Get-VBRRestorePoint -Backup $backup
Export-VBRRestorePoint -RestorePoint $rps[-1]
$date = Get-Date -Format "yyyy-MM-dd"
$backupName = "$($rps[-1].Name)_$date"
$exportedBackup = Get-VBRBackup | where {$_.OriginalId -eq $backup.Id `
-and $_.Id -ne $backup.Id -and $_.Name -match $backupName}
$exportedBackup
So, unless you exported a restore point for the same machine of the very same backup few times a day already, looks like it shows a singular result.

Thanks,
Oleg
david.domask
Veeam Software
Posts: 1226
Liked: 323 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Reference to the files created with export-vbrrestorepoint

Post by david.domask »

Oh wow! I didn't realize OriginalID actually had a use; thanks @oleg.feoktistov!! I guess maybe @Mildur can remove the first part of my post and just leave the link to finding the fully qualified path of the files, as I suspect that part is still required if it's on Scaleout Repository.
David Domask | Product Management: Principal Analyst
David_S
Novice
Posts: 3
Liked: never
Joined: Jan 21, 2020 1:56 pm
Full Name: David Sjöstrand
Contact:

Re: Reference to the files created with export-vbrrestorepoint

Post by David_S »

Mildur wrote: Oct 28, 2022 8:13 am Hi David

May I know the use case?
You could also use a backup copy job. That would also allow you to automatically "moving away a backup file".
And you can monitor it in the console.

But yes, it would make sense to output the exported path so the backup can be reused for a second command.
I'll try it out myself in the lab.

Thanks
Fabian
I need to move a restore point from january for all backed up vms (a few hundred) to another disk (to keep indefinitely). As the export command does not allow me to export to any other repository than the one the backup is on (which also is very weird), and I am limited in space on those repositories, I need to export one restore point, copy it, and then remove the exported files before moving on to the next restore point. All of this has to be automated, and I will have to leave the script running for days or weeks, probably, during which I won't be able to constantly monitor the script. This is why I would like as little ambiguity as possible.
Mildur
Product Manager
Posts: 8735
Liked: 2296 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Reference to the files created with export-vbrrestorepoint

Post by Mildur »

Hi David

Thanks for explaining the use case.
As the export command does not allow me to export to any other repository than the one the backup is on (which also is very weird)
Using another repository should be possible starting in V12. Let me check and update my comment if not.
Product Management Analyst @ Veeam Software
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests