-
- Novice
- Posts: 6
- Liked: never
- Joined: Feb 03, 2022 8:22 pm
- Full Name: Syltrem
- Contact:
Get-VBRBackupFile
Hi
This cmdlet returns the file NAME that contains a specific backup's data, but it does not show the PATH to that file.
Is there any way to find the path ?
$backup = Get-VBRBackup -Name "MyBackup"
$backup | select-object name, RepositoryId
The name does not include the path, and although I could possibly inquire about the repository, it contains many extents and the file could be in any one, so that wouldn't help much.
Thanks for any hint
This cmdlet returns the file NAME that contains a specific backup's data, but it does not show the PATH to that file.
Is there any way to find the path ?
$backup = Get-VBRBackup -Name "MyBackup"
$backup | select-object name, RepositoryId
The name does not include the path, and although I could possibly inquire about the repository, it contains many extents and the file could be in any one, so that wouldn't help much.
Thanks for any hint
-
- VeeaMVP
- Posts: 695
- Liked: 374 times
- Joined: Jun 24, 2019 1:39 pm
- Full Name: Chris Arceneaux
- Location: Georgia, USA
- Contact:
Re: Get-VBRBackupFile
Welcome to the Veeam forums!
Thanks for the feedback. Am I correct that you're looking for the full file path of the file? If so, the below code will point you in the right direction.
Thanks for the feedback. Am I correct that you're looking for the full file path of the file? If so, the below code will point you in the right direction.
Code: Select all
# Retrieve Job
$job = Get-VBRJob -Name "Job Name"
# Find backup related to Job
$backup = Get-VBRBackup | Where-Object {$_.JobId -eq $job.Id}
# Retrieve backup storage
$storages = $backup.GetAllChildrenStorages()
# List filepath and server of a single storage
# Filepath
$storages[0].FilePath.ToString()
# Server name
$server = Get-VBRServer | Where-Object {$_.Id -eq $storages[0].HostId}
$server.Name
-
- Novice
- Posts: 6
- Liked: never
- Joined: Feb 03, 2022 8:22 pm
- Full Name: Syltrem
- Contact:
Re: Get-VBRBackupFile
Hi Chris
Thanks for your reply.
>>> Am I correct that you're looking for the full file path of the file?
Yes indeed
Any way I look at it, mine does not show the path. Pretty strange.
Maybe a problem with version 10 ? Not yet on 11...
PS C:\Users\Administrator.ZZZCO-DOM> (Get-PSSnapin VeeamPSSnapin).Version
Major Minor Build Revision
----- ----- ----- --------
10 0 0 0
PS C:\Users\Administrator.ZZZCO-DOM> $storages = $backup.GetAllChildrenStorages()
PS C:\Users\Administrator.ZZZCO-DOM> $storages[0].FilePath.ToString()
ZZZ Servers - BMR - ZZZHV02D2022-01-11T125834_CB88.vib
PS C:\Users\Administrator.ZZZCO-DOM> $storages[1].FilePath.ToString()
ZZZ Servers - BMR - ZZZHV02D2022-01-25T120051_10CC.vib
PS C:\Users\Administrator.ZZZCO-DOM> $storages[7].FilePath.ToString()
ZZZ Servers - BMR - ZZZHV02D2022-02-03T120044_43E3.vbk
also
S C:\Users\Administrator.ZZZCO-DOM> $storages | select-object filepath
ilePath
-------
ZZZ Servers - BMR - ZZZHV02D2022-01-11T125834_CB88.vib
ZZZ Servers - BMR - ZZZHV02D2022-01-25T120051_10CC.vib
ZZZ Servers - BMR - ZZZHV02D2022-01-27T131221_C89A.vbk
ZZZ Servers - BMR - ZZZHV02D2022-01-13T122536_DEE7.vbk
ZZZ Servers - BMR - ZZZHV02D2022-02-01T131238_642E.vib
ZZZ Servers - BMR - ZZZHV02D2022-01-06T125501_3ED1.vbk
ZZZ Servers - BMR - ZZZHV02D2022-01-18T131059_B384.vib
ZZZ Servers - BMR - ZZZHV02D2022-02-03T120044_43E3.vbk
ZZZ Servers - BMR - ZZZHV02D2022-01-20T120046_921D.vbk
and
PS C:\Users\Administrator.ZZZCO-DOM> $files = Get-VBRBackupFile -Backup $backup
PS C:\Users\Administrator.ZZZCO-DOM> $files
Path Id
---- --
ZZZ Servers - BMR - ZZZHV02D2022-01-11T125834_CB88.vib f4f8adcc-ae11-4a7d-8a07-17b0a593469c
ZZZ Servers - BMR - ZZZHV02D2022-01-25T120051_10CC.vib 0446e0ef-db42-4a7d-9fd2-476c70500a06
ZZZ Servers - BMR - ZZZHV02D2022-01-27T131221_C89A.vbk 616290ac-1ade-4f94-9583-4ecddb864853
ZZZ Servers - BMR - ZZZHV02D2022-01-13T122536_DEE7.vbk a52bd3f1-6973-426f-bddc-7b3fdea3c929
ZZZ Servers - BMR - ZZZHV02D2022-02-01T131238_642E.vib 27073adb-97e2-40a6-ae56-810edddd4935
ZZZ Servers - BMR - ZZZHV02D2022-01-06T125501_3ED1.vbk 6b6be311-9d3c-45b4-ab9e-8e1b37929a21
ZZZ Servers - BMR - ZZZHV02D2022-01-18T131059_B384.vib 526c4775-fef7-4bbf-838e-ca4380c451a3
ZZZ Servers - BMR - ZZZHV02D2022-02-03T120044_43E3.vbk 2abd2b24-bc87-4357-abf6-da2d4a3de83c
ZZZ Servers - BMR - ZZZHV02D2022-01-20T120046_921D.vbk 65c19105-7603-483a-8173-e0b9d81a03a1
Thanks for your reply.
>>> Am I correct that you're looking for the full file path of the file?
Yes indeed
Any way I look at it, mine does not show the path. Pretty strange.
Maybe a problem with version 10 ? Not yet on 11...
PS C:\Users\Administrator.ZZZCO-DOM> (Get-PSSnapin VeeamPSSnapin).Version
Major Minor Build Revision
----- ----- ----- --------
10 0 0 0
PS C:\Users\Administrator.ZZZCO-DOM> $storages = $backup.GetAllChildrenStorages()
PS C:\Users\Administrator.ZZZCO-DOM> $storages[0].FilePath.ToString()
ZZZ Servers - BMR - ZZZHV02D2022-01-11T125834_CB88.vib
PS C:\Users\Administrator.ZZZCO-DOM> $storages[1].FilePath.ToString()
ZZZ Servers - BMR - ZZZHV02D2022-01-25T120051_10CC.vib
PS C:\Users\Administrator.ZZZCO-DOM> $storages[7].FilePath.ToString()
ZZZ Servers - BMR - ZZZHV02D2022-02-03T120044_43E3.vbk
also
S C:\Users\Administrator.ZZZCO-DOM> $storages | select-object filepath
ilePath
-------
ZZZ Servers - BMR - ZZZHV02D2022-01-11T125834_CB88.vib
ZZZ Servers - BMR - ZZZHV02D2022-01-25T120051_10CC.vib
ZZZ Servers - BMR - ZZZHV02D2022-01-27T131221_C89A.vbk
ZZZ Servers - BMR - ZZZHV02D2022-01-13T122536_DEE7.vbk
ZZZ Servers - BMR - ZZZHV02D2022-02-01T131238_642E.vib
ZZZ Servers - BMR - ZZZHV02D2022-01-06T125501_3ED1.vbk
ZZZ Servers - BMR - ZZZHV02D2022-01-18T131059_B384.vib
ZZZ Servers - BMR - ZZZHV02D2022-02-03T120044_43E3.vbk
ZZZ Servers - BMR - ZZZHV02D2022-01-20T120046_921D.vbk
and
PS C:\Users\Administrator.ZZZCO-DOM> $files = Get-VBRBackupFile -Backup $backup
PS C:\Users\Administrator.ZZZCO-DOM> $files
Path Id
---- --
ZZZ Servers - BMR - ZZZHV02D2022-01-11T125834_CB88.vib f4f8adcc-ae11-4a7d-8a07-17b0a593469c
ZZZ Servers - BMR - ZZZHV02D2022-01-25T120051_10CC.vib 0446e0ef-db42-4a7d-9fd2-476c70500a06
ZZZ Servers - BMR - ZZZHV02D2022-01-27T131221_C89A.vbk 616290ac-1ade-4f94-9583-4ecddb864853
ZZZ Servers - BMR - ZZZHV02D2022-01-13T122536_DEE7.vbk a52bd3f1-6973-426f-bddc-7b3fdea3c929
ZZZ Servers - BMR - ZZZHV02D2022-02-01T131238_642E.vib 27073adb-97e2-40a6-ae56-810edddd4935
ZZZ Servers - BMR - ZZZHV02D2022-01-06T125501_3ED1.vbk 6b6be311-9d3c-45b4-ab9e-8e1b37929a21
ZZZ Servers - BMR - ZZZHV02D2022-01-18T131059_B384.vib 526c4775-fef7-4bbf-838e-ca4380c451a3
ZZZ Servers - BMR - ZZZHV02D2022-02-03T120044_43E3.vbk 2abd2b24-bc87-4357-abf6-da2d4a3de83c
ZZZ Servers - BMR - ZZZHV02D2022-01-20T120046_921D.vbk 65c19105-7603-483a-8173-e0b9d81a03a1
-
- Veeam Software
- Posts: 2123
- Liked: 513 times
- Joined: Jun 28, 2016 12:12 pm
- Contact:
Re: Get-VBRBackupFile
Hi Tremblay,
Are these backups on a Scale Out Repository by chance? (SOBR)
SOBR uses a relative path for tracking the files so you need to do some construction of the path from the Repository Path, the Job Name, and the backup file name.
The following was written for another script purpose but should help in v11. Pass it a Backup Object fetched with Get-VBRRBackup and it should work. (Borrows a bit from Tim's code here, but updated for v10/v11 as there were some changes): powershell-f26/get-all-used-backup-repo ... ml#p279960)
Are these backups on a Scale Out Repository by chance? (SOBR)
SOBR uses a relative path for tracking the files so you need to do some construction of the path from the Repository Path, the Job Name, and the backup file name.
The following was written for another script purpose but should help in v11. Pass it a Backup Object fetched with Get-VBRRBackup and it should work. (Borrows a bit from Tim's code here, but updated for v10/v11 as there were some changes): powershell-f26/get-all-used-backup-repo ... ml#p279960)
Code: Select all
function Get-StoragesPathsAndBlocksizeFromBackup-v11 {
param(
[Parameter(Mandatory=$true, Position=0)]
[Object[]]$Backup
)
$Storages = $Backup[0].GetallChildrenStorages() | Sort-Object -Property PartialPath, CreationTime -Descending
$Repository = $Backup.FindRepository()[0]
$StoragePathsandBlocksize = @()
if($Repository.Type -eq "ExtendableRepository"){
foreach($Storage in $Storages){
$Extent = $Repository.FindRepositoryForExistingStorage($Storage.Id)
if($Backup.JobID -eq '00000000-0000-0000-0000-000000000000'){
$JobName = $Backup.GetMetaFilePath().Elements[0]
}Else{
$jobName = $Backup.FindJob().Name
}
$StoragePathsandBlocksize += New-Object -TypeName psobject -Property @{Extent=$Extent.Name;Path=$($Extent.Path.ToString(),$JobName.ToString(),$Storage.filepath -join "\");BlockSize=$Storage.BlockAlignmentSize;CreationTime=$Storage.CreationTime}
}
} else {
$StoragePathsandBlocksize += $Storages | Sort-Object -Property PartialPath, CreationTime -Descending | Select-Object -Property PartialPath,BlockAlignmentSize
}
return $StoragePathsandBlocksize
}
David Domask | Product Management: Principal Analyst
-
- Veeam Software
- Posts: 2123
- Liked: 513 times
- Joined: Jun 28, 2016 12:12 pm
- Contact:
Re: Get-VBRBackupFile
Oh, small whoops as I realize you wrote you're on v10; one of the methods was different there. Use the following if you're on v10:
v10 Version
v10 Version
Code: Select all
function Get-StoragesPathsAndBlocksizeFromBackup-v10 {
param(
[Parameter(Mandatory=$true, Position=0)]
[Object[]]$Backup
)
if($Backup.JobType -eq 'EpAgentBackup' -or $Backup.Jobtype -eq 'SimpleBackupCopyPolicy'){
$Storages = $Backup[0].GetallChildrenStorages() | Sort-Object -Property PartialPath, CreationTime -Descending
} else {
$Storages = $Backup[0].GetAllStorages() | Sort-Object -Property PartialPath, CreationTime -Descending
}
$Repository = $Backup.FindRepository()[0]
$StoragePathsandBlocksize = @()
if($Repository.Type -eq "ExtendableRepository"){
foreach($Storage in $Storages){
$Extent = $Repository.FindExtentRepo($Storage.Id)
$job = $Backup.FindJob()
$StoragePathsandBlocksize += New-Object -TypeName psobject -Property @{Extent=$Extent.Name;Path=$($Extent.Path.ToString(),$job.Name.ToString(),$Storage.filepath -join "\");BlockSize=$Storage.BlockAlignmentSize;CreationTime=$Storage.CreationTime}
}
} else {
$StoragePathsandBlocksize += $Storages | Sort-Object -Property PartialPath, CreationTime -Descending | Select-Object -Property PartialPath,BlockAlignmentSize
}
return $StoragePathsandBlocksize
}
David Domask | Product Management: Principal Analyst
-
- Novice
- Posts: 6
- Liked: never
- Joined: Feb 03, 2022 8:22 pm
- Full Name: Syltrem
- Contact:
Re: Get-VBRBackupFile
Thanks for sharing David, exactly what I needed and really not something easy for me to devise ! I'm glad you have it for both V10 and V11, too.
Have a great weekend !
Have a great weekend !
-
- Novice
- Posts: 6
- Liked: never
- Joined: Feb 03, 2022 8:22 pm
- Full Name: Syltrem
- Contact:
Re: Get-VBRBackupFile
Hi
Although this is working fine to retrieve the info about the files, how can I add the required value to $StoragePathsandBlocksize to use with :
Start-VBROffloadBackupFile -BackupFile ??????? -ThisBackupAndIncrements
The $files.path variable is not suitable for this and I tried different things to no avail...
This is how I select the files I'd like to offload :
$files = Get-StoragesPathsAndBlocksizeFromBackup-v10($backups) `
| Where-Object {[System.IO.Path]::GetExtension($_.Path) -like ".vbk" -and $_.CreationTime -lt (get-date).AddDays(-22)}
Error message :
Cannot convert the "C:\my path\file.vbk" value of type "System.String" to type "Veeam.Backup.PowerShell.Infos.VBRBackupFile".
Also, I noted that the Path variable contains the string "System.Object[]" for some reason
Path : V:\Veeam Backups\System.Object[]\SIQ Servers - BMR - SIQSV02D2022-01-20T200735_9315.vbk
Your help is very much appreciated.
Thank you
Although this is working fine to retrieve the info about the files, how can I add the required value to $StoragePathsandBlocksize to use with :
Start-VBROffloadBackupFile -BackupFile ??????? -ThisBackupAndIncrements
The $files.path variable is not suitable for this and I tried different things to no avail...
This is how I select the files I'd like to offload :
$files = Get-StoragesPathsAndBlocksizeFromBackup-v10($backups) `
| Where-Object {[System.IO.Path]::GetExtension($_.Path) -like ".vbk" -and $_.CreationTime -lt (get-date).AddDays(-22)}
Error message :
Cannot convert the "C:\my path\file.vbk" value of type "System.String" to type "Veeam.Backup.PowerShell.Infos.VBRBackupFile".
Also, I noted that the Path variable contains the string "System.Object[]" for some reason
Path : V:\Veeam Backups\System.Object[]\SIQ Servers - BMR - SIQSV02D2022-01-20T200735_9315.vbk
Your help is very much appreciated.
Thank you
-
- Veeam Software
- Posts: 2123
- Liked: 513 times
- Joined: Jun 28, 2016 12:12 pm
- Contact:
Re: Get-VBRBackupFile
Hi Tremblay!
Well, in fact it's telling you the issue What you originally asked for was a list of File Names, which is what my code gives you, but you need a specific CStorage object.
https://helpcenter.veeam.com/docs/backu ... ml?ver=110
This cmdlet needs a specific object for the -BackupFile parameter, and you might check the example:
So you need something like this:
This will return an array of the backup files that you can pass.
So your issue was just a slight misunderstanding on what the cmdlet you were working with
Let me know if this helps!
Well, in fact it's telling you the issue What you originally asked for was a list of File Names, which is what my code gives you, but you need a specific CStorage object.
https://helpcenter.veeam.com/docs/backu ... ml?ver=110
This cmdlet needs a specific object for the -BackupFile parameter, and you might check the example:
Code: Select all
$backup = Get-VBRBackup -Name "Exchange backups"
$files = Get-VBRBackupFile -Backup $backup
Start-VBROffloadBackupFile -BackupFile $files -ThisBackup
Code: Select all
PS C:\Users\Administrator> $job
Job Name Type State Last Result Description
-------- ---- ----- ----------- -----------
classic-bcj VMware Backu... Idle None #corebackup
PS C:\Users\Administrator> $backup = Get-VBRBackup -name $job.name
PS C:\Users\Administrator> $backup
Job Name Type Creation Time VM count
-------- ---- ------------- --------
classic-bcj VMware Backu... 2/17/2021 13:15:51 3
PS C:\Users\Administrator> Get-VBRBackupFile -Backup $backup
Path IsAvailable Id
---- ----------- --
DDom-TinyVM-vrdm.vm-23625D2022-02-03T060000_8389.vib True 1fabee86-5f86-4b2f-bd51-010fb53e66b5
DDom-TinyVM-vrdm.vm-23625D2022-02-08T060000_E5EB.vib True 92f2a9f7-8504-4086-ac6a-0b2d5ad4268e
DDom-TinyVM-vrdm.vm-23625D2022-01-12T060000_CE19.vib True b6079ea1-9ac8-4066-9384-2c1ab4a2f902
DDom-TinyVM-vrdm.vm-23625D2022-02-12T060000_D815.vib True f701a25b-e44f-4fc9-ade3-3083280b28bc
DDom-TinyVM-vrdm.vm-23625D2022-02-07T060000_57AB.vib True 4ef2fd28-93f3-498e-ba53-33531fa64f32
DDom-TinyVM-vrdm.vm-23625D2022-02-02T060000_4173.vib True 523a0d88-a90b-480c-a5af-47f2a80f4008
DDom-TinyVM-vrdm.vm-23625D2021-12-13T060000_3867.vib True 56975b6c-0c49-4776-b3ce-506d28618d82
DDom-TinyVM-vrdm.vm-23625D2022-02-14T060000_E833.vib True 97309927-2259-49a5-94c9-51ddeac391ee
...
So your issue was just a slight misunderstanding on what the cmdlet you were working with
Let me know if this helps!
David Domask | Product Management: Principal Analyst
-
- Novice
- Posts: 6
- Liked: never
- Joined: Feb 03, 2022 8:22 pm
- Full Name: Syltrem
- Contact:
Re: Get-VBRBackupFile
Hi
I understand what you're saying but I was looking for a way to add the value returned by VBRBackupFile into the $StoragePathsandBlocksize returned by the Get-StoragesPathsAndBlocksizeFromBackup-v10 function.
Thanks
I understand what you're saying but I was looking for a way to add the value returned by VBRBackupFile into the $StoragePathsandBlocksize returned by the Get-StoragesPathsAndBlocksizeFromBackup-v10 function.
Thanks
-
- Veeam Software
- Posts: 2123
- Liked: 513 times
- Joined: Jun 28, 2016 12:12 pm
- Contact:
Re: Get-VBRBackupFile
Er, well I think maybe there's a misunderstanding.
Like I said, the code I provided provides file paths; SOBR is tricky because it has to build the path.
But the SOBR offload cmdlet doesn't want that; it wants a CStorage object, which is what Get-VBRBackupFile returns.
A CStorage object carries information from the database about a Storage, which in Veeam terminology means backup file. The Veeam you're trying to use doesn't need to know the full path, it just needs to know which storage you want, and Veeam handles the rest behind the scenes. The ID is more important than the path. So in this case, you want the output of Get-VBRRBackupFile "as-is", and Veeam knows what to do.
So maybe you can explain why you want the file path when the cmdlet doesn't want or need it; the cmdlet is looking for the CStorage object, and from that, Veeam knows everything about a given storage.
Maybe you can elaborate more on what specifically you're trying to do -- maybe there are some backups that aren't offloading that you want to be offloaded? If so we need more details on those backups (type of backup, where they're stored, etc).
But if the goal is just to manually manage the offloading, then the example and the output of Get-VBRBackupFile is exactly what you want.
So maybe you can elaborate on the challenge you're currently facing, as in fact for the offload cmdlet you don't need the full path at all at any point.
Like I said, the code I provided provides file paths; SOBR is tricky because it has to build the path.
But the SOBR offload cmdlet doesn't want that; it wants a CStorage object, which is what Get-VBRBackupFile returns.
A CStorage object carries information from the database about a Storage, which in Veeam terminology means backup file. The Veeam you're trying to use doesn't need to know the full path, it just needs to know which storage you want, and Veeam handles the rest behind the scenes. The ID is more important than the path. So in this case, you want the output of Get-VBRRBackupFile "as-is", and Veeam knows what to do.
So maybe you can explain why you want the file path when the cmdlet doesn't want or need it; the cmdlet is looking for the CStorage object, and from that, Veeam knows everything about a given storage.
Maybe you can elaborate more on what specifically you're trying to do -- maybe there are some backups that aren't offloading that you want to be offloaded? If so we need more details on those backups (type of backup, where they're stored, etc).
But if the goal is just to manually manage the offloading, then the example and the output of Get-VBRBackupFile is exactly what you want.
So maybe you can elaborate on the challenge you're currently facing, as in fact for the offload cmdlet you don't need the full path at all at any point.
David Domask | Product Management: Principal Analyst
-
- Veeam Software
- Posts: 2123
- Liked: 513 times
- Joined: Jun 28, 2016 12:12 pm
- Contact:
Re: Get-VBRBackupFile
Necro-bump, but fixed this function to work with v12 and 12.1. I've just tested on VM and Agent backups, not sure how it will play with other job types
Code: Select all
function Get-StoragesPathsAndBlocksizeFromBackup-v12 {
param(
[Parameter(Mandatory=$true, Position=0)]
[Object[]]$Backup
)
$Storages = $Backup[0].GetallChildrenStorages() | Sort-Object -Property PartialPath, CreationTime -Descending
$Repository = $Backup.FindRepository()[0]
$StoragePathsandBlocksize = @()
if($Repository.Type -eq "ExtendableRepository"){
foreach($Storage in $Storages){
$Extent = $Repository.GetRepositoryForExistingStorage($Storage.Id)
if($Backup.JobID -eq '00000000-0000-0000-0000-000000000000'){
$JobName = $Backup.GetMetaFilePath().Elements[0]
}Else{
$jobName = $Backup.FindJob().Name
}
$StoragePathsandBlocksize += New-Object -TypeName psobject -Property @{Extent=$Extent.Name;Path=$($Extent.Path.ToString(),$JobName.ToString(),$Storage.filepath -join "\");BlockSize=$Storage.BlockAlignmentSize;CreationTime=$Storage.CreationTime}
}
} else {
$StoragePathsandBlocksize += $Storages | Sort-Object -Property PartialPath, CreationTime -Descending | Select-Object -Property PartialPath,BlockAlignmentSize
}
return $StoragePathsandBlocksize
}
david.domask wrote: ↑Feb 04, 2022 6:18 am
Code: Select all
function Get-StoragesPathsAndBlocksizeFromBackup-v11 { param( [Parameter(Mandatory=$true, Position=0)] [Object[]]$Backup ) $Storages = $Backup[0].GetallChildrenStorages() | Sort-Object -Property PartialPath, CreationTime -Descending $Repository = $Backup.FindRepository()[0] $StoragePathsandBlocksize = @() if($Repository.Type -eq "ExtendableRepository"){ foreach($Storage in $Storages){ $Extent = $Repository.FindRepositoryForExistingStorage($Storage.Id) if($Backup.JobID -eq '00000000-0000-0000-0000-000000000000'){ $JobName = $Backup.GetMetaFilePath().Elements[0] }Else{ $jobName = $Backup.FindJob().Name } $StoragePathsandBlocksize += New-Object -TypeName psobject -Property @{Extent=$Extent.Name;Path=$($Extent.Path.ToString(),$JobName.ToString(),$Storage.filepath -join "\");BlockSize=$Storage.BlockAlignmentSize;CreationTime=$Storage.CreationTime} } } else { $StoragePathsandBlocksize += $Storages | Sort-Object -Property PartialPath, CreationTime -Descending | Select-Object -Property PartialPath,BlockAlignmentSize } return $StoragePathsandBlocksize }
David Domask | Product Management: Principal Analyst
-
- Influencer
- Posts: 14
- Liked: 7 times
- Joined: Sep 17, 2021 7:03 am
- Full Name: Allan Warner
- Contact:
Re: Get-VBRBackupFile
You beauty @David.
I couldn't figure out how to get the full path for the files on my SOBR on V12.
Thanks so much for this.
I couldn't figure out how to get the full path for the files on my SOBR on V12.
Thanks so much for this.
-
- Influencer
- Posts: 14
- Liked: 7 times
- Joined: Sep 17, 2021 7:03 am
- Full Name: Allan Warner
- Contact:
Re: Get-VBRBackupFile
Hi David,
Hope you don't mind, I took your awesome example and have changed it for my purpose which I just needed the path for the specific files on the SOBR.
I have also removed the spaces and colons from the job names which are prohibited in the path, and converted to underscores... I have just called the storage object $backupfile (as it made more sense to me )
So you can just supply the backup object and the storage object (backupfile) and get the filepath returned with prohibited characters replaced for underscores.
Hope you don't mind, I took your awesome example and have changed it for my purpose which I just needed the path for the specific files on the SOBR.
I have also removed the spaces and colons from the job names which are prohibited in the path, and converted to underscores... I have just called the storage object $backupfile (as it made more sense to me )
So you can just supply the backup object and the storage object (backupfile) and get the filepath returned with prohibited characters replaced for underscores.
Code: Select all
function Get-SOBRBackupFilePathFromBackupV12 {
param(
[Parameter(Mandatory=$true, Position=0)]
[Object[]]$Backup,
[Parameter(Mandatory=$true, Position=1)]
[Object[]]$backupfile
)
$Repository = $Backup.FindRepository()[0];
if($Repository.Type -eq "ExtendableRepository"){
$Extent = $Repository.GetRepositoryForExistingStorage($backupfile.Id);
if($Backup.JobID -eq '00000000-0000-0000-0000-000000000000'){
$JobName = $Backup.GetMetaFilePath().Elements[0];
}Else{
$jobName = $Backup.FindJob().Name;
}
$BackupFileSOBRSANPath = "$($Extent.Path.ToString(),$JobName.ToString(),$backupfile.filepath -join "/")";
} else {
$BackupFileSOBRSANPath = $backupfile.PartialPath;
}
#Replace prohibitied path characters
$BackupFileSOBRSANPath = $BackupFileSOBRSANPath -replace ' |:', '_'
return $BackupFileSOBRSANPath;
}
-
- Influencer
- Posts: 14
- Liked: 7 times
- Joined: Sep 17, 2021 7:03 am
- Full Name: Allan Warner
- Contact:
Re: Get-VBRBackupFile
Ok, update....
With my setup the backup copy jobs have source Backup jobs... So that gets added to the path on the SOBR... So my above script didnot account for this... I now have the following... it looks up the linkedIDs of the jobs...
I am far from an expert, and I need to look at the diffference between jobs and backups (in regards to VBR powershell and Veeam), as not both objects have the linkedIDs...
Anyway I am about to leave for home so I am posting the following as it works... but it is slow... I think I might rework and load into objects into memory, and use from there instead of querying Veeam Powershell commands each time.. If i do i will post here.
But for now this works, and maybe it will help someone.... somewhere....
With my setup the backup copy jobs have source Backup jobs... So that gets added to the path on the SOBR... So my above script didnot account for this... I now have the following... it looks up the linkedIDs of the jobs...
I am far from an expert, and I need to look at the diffference between jobs and backups (in regards to VBR powershell and Veeam), as not both objects have the linkedIDs...
Anyway I am about to leave for home so I am posting the following as it works... but it is slow... I think I might rework and load into objects into memory, and use from there instead of querying Veeam Powershell commands each time.. If i do i will post here.
But for now this works, and maybe it will help someone.... somewhere....
Code: Select all
function Get-SOBRBackupFilePathFromBackupV12 {
param(
[Parameter(Mandatory=$true, Position=0)]
[Object]$Backup,
[Parameter(Mandatory=$true, Position=1)]
[Object]$backupfile
)
$Repository = $Backup.FindRepository()[0];
if($Repository.Type -eq "ExtendableRepository"){
$Extent = $Repository.GetRepositoryForExistingStorage($backupfile.Id);
if($Backup.JobID -eq '00000000-0000-0000-0000-000000000000'){
$JobName = $Backup.GetMetaFilePath().Elements[0];
}Else{
$jobName = $Backup.FindJob().Name;
}
#Get Source backup job
$BackupCopyJob = Get-VBRJob -Name $backup.Name;
$SourceJob = Get-VBRBackup | Where-Object {$BackupCopyJob.LinkedJobIds.Guid -eq $_.JobId.guid};
$BackupFileSOBRSANPath = "$($Extent.Path.ToString(),$JobName.ToString(),$SourceJob.jobname.ToString(),$backupfile.filepath -join "/")";
} else {
$BackupFileSOBRSANPath = $backupfile.PartialPath;
}
#Replace prohibitied path characters
$BackupFileSOBRSANPath = $BackupFileSOBRSANPath -replace ' |:', '_';
return $BackupFileSOBRSANPath;
}
-
- Veeam Software
- Posts: 2123
- Liked: 513 times
- Joined: Jun 28, 2016 12:12 pm
- Contact:
Re: Get-VBRBackupFile
Hi Allan,
Oh thank you very much for the update on this script! And of course, alterations and customizations are _always welcomed_ for the code, it's why we share it here, so thank you very much for sharing your script, it will be useful for many, I am positive about this If I could give more than likes I would
Oh thank you very much for the update on this script! And of course, alterations and customizations are _always welcomed_ for the code, it's why we share it here, so thank you very much for sharing your script, it will be useful for many, I am positive about this If I could give more than likes I would
David Domask | Product Management: Principal Analyst
-
- Influencer
- Posts: 14
- Liked: 7 times
- Joined: Sep 17, 2021 7:03 am
- Full Name: Allan Warner
- Contact:
Re: Get-VBRBackupFile
Ok, last update from me... The lookup of the associated backup job to the copy job is very very expensive (slow). Looking at it a bit more the lookuponly needs to occur once by backup copy job that I am looping through.. So I have moved it outside of this function, and now just pass in the backup job name as a string (SourceBackup).
So the call to the function now looks like this...
Code: Select all
function Get-SOBRBackupFilePathFromBackupV12 {
param(
[Parameter(Mandatory=$true, Position=0)]
[Object]$Backup,
[Parameter(Mandatory=$true, Position=1)]
[Object]$backupfile,
[Parameter(Mandatory=$true, Position=2)]
[String]$SourceBackup
)
write-host "processing $($backupfile.FilePath)";
$Repository = $Backup.FindRepository()[0];
if($Repository.Type -eq "ExtendableRepository"){
$Extent = $Repository.GetRepositoryForExistingStorage($backupfile.Id);
if($Backup.JobID -eq '00000000-0000-0000-0000-000000000000'){
$JobName = $Backup.GetMetaFilePath().Elements[0];
}Else{
$jobName = $Backup.FindJob().Name;
}
$BackupFileSOBRSANPath = "$($Extent.Path.ToString(),$JobName.ToString(),$SourceBackup.ToString(),$backupfile.filepath -join "/")";
} else {
$BackupFileSOBRSANPath = $backupfile.PartialPath;
}
#Replace prohibitied path characters
$BackupFileSOBRSANPath = $BackupFileSOBRSANPath -replace ' |:', '_';
return $BackupFileSOBRSANPath;
}
Code: Select all
$backupFileSOBRSANPath = Get-SOBRBackupFilePathFromBackupV12 -Backup $backup -backupfile $backupFile -SourceBackup $SourceBackup.jobname;
-
- Influencer
- Posts: 14
- Liked: 7 times
- Joined: Sep 17, 2021 7:03 am
- Full Name: Allan Warner
- Contact:
Re: Get-VBRBackupFile
Well looks like i lied.. not my last post...
I hit an issue, on our hardened SOBR I came across folders with Backup Copy job name but with _1...
I am guessing that someone had deleted and recreated the Backup Copy Job... So Veeam has created a folder with Backup Copy Name, but with _1, as there is already a folder with the job name...
So i have changed the function, to not use the job name, but use the actual path to create the full file path. For me I have commented out the jobname section as I don't think I need it.. (I am not fully sure what the $Backup.JobID -eq '00000000-0000-0000-0000-000000000000' means);
$jobname.ToString now becomes $Backup.DirPath.ToString()
I hit an issue, on our hardened SOBR I came across folders with Backup Copy job name but with _1...
I am guessing that someone had deleted and recreated the Backup Copy Job... So Veeam has created a folder with Backup Copy Name, but with _1, as there is already a folder with the job name...
So i have changed the function, to not use the job name, but use the actual path to create the full file path. For me I have commented out the jobname section as I don't think I need it.. (I am not fully sure what the $Backup.JobID -eq '00000000-0000-0000-0000-000000000000' means);
$jobname.ToString now becomes $Backup.DirPath.ToString()
Code: Select all
function Get-SOBRBackupFilePathFromBackupV12 {
param(
[Parameter(Mandatory=$true, Position=0)]
[Object]$Backup,
[Parameter(Mandatory=$true, Position=1)]
[Object]$backupfile,
[Parameter(Mandatory=$true, Position=2)]
[String]$SourceBackup
)
write-host "processing $($backupfile.FilePath)";
$Repository = $Backup.FindRepository()[0];
if($Repository.Type -eq "ExtendableRepository"){
$Extent = $Repository.GetRepositoryForExistingStorage($backupfile.Id);
<#if($Backup.JobID -eq '00000000-0000-0000-0000-000000000000'){
$JobName = $Backup.GetMetaFilePath().Elements[0];
}Else{
$jobName = $Backup.FindJob().Name;
}#>
$BackupFileSOBRSANPath = "$($Extent.Path.ToString(),$Backup.DirPath.ToString(),$SourceBackup.ToString(),$backupfile.filepath -join "/")";
} else {
$BackupFileSOBRSANPath = $backupfile.PartialPath;
}
#Replace prohibitied path characters
$BackupFileSOBRSANPath = $BackupFileSOBRSANPath -replace ' |:', '_';
return $BackupFileSOBRSANPath;
}
Who is online
Users browsing this forum: No registered users and 10 guests