PowerShell script exchange
Post Reply
TimLawhead
Influencer
Posts: 21
Liked: 3 times
Joined: Mar 05, 2019 3:29 pm
Full Name: Tim Lawhead
Contact:

Enumerate files in a backup repository - with no backup job/.vbm file

Post by TimLawhead »

Hello All,

I had a backup copy job that was deleted but the files are still on a HPE StoreOnce. VBR Forum Post

I found I can use the Files in the VBR client, go to the directory on the StoreOnce and delete the files, but I can't import them as a group.

Following the Get-VBRBAckupRepository Example 2, I was able to get 1 file from the folder in.

Since it looks like that method is only meant to be used with a direct file path and a wildcard can't be used to grab multiple files, what I'd like is to figure out a way to pull a list of all the .vbk/.vib files that exist in that directory and then use a Foreach loop with the Example 2 to import them.

I tried the File list from all repositories but it leaves out the folder that is missing the .vbm and doesn't show as imported when I rescan the repo.

Any suggestions are appreciated. TIA

oleg.feoktistov
Veeam Software
Posts: 391
Liked: 125 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Enumerate files in a backup repository - with no backup job/.vbm file

Post by oleg.feoktistov » 1 person likes this post

Hi Tim,

Well, normally that would involve some cmdlets querying file tree structure on StoreOnce appliances.
But since we don’t have any, you could simulate "Files" pane browsing with .NET methods to get all backups and then import them by their direct links:

Code: Select all

asnp VeeamPSSnapin
$repository = Get-VBRBackupRepository | where {$_.Type -eq 'HPStoreOnceIntegration'}
$accessor = [Veeam.Backup.Core.CRepositoryAccessorFactory]::Create($repository)
$items = $accessor.FileCommander.EnumItems($repository.Path)
$fulls = @()
foreach ($item in $items) {
$folder = $repository.FriendlyPath + $item.Name
$backups = $accessor.FileCommander.EnumItems($folder)
 foreach ($backup in $backups) {
    if ($backup.Name -like '*vbk') {
        $fulls += $backup
    }
  }
}
 foreach ($full in $fulls) {
    Import-VBRBackup -Repository $repository -FileName $full.FullName
 }
The code above, for instance, imports all .vbk files from all StoreOnce appliance folders.

Hope that helps you out!

Oleg

TimLawhead
Influencer
Posts: 21
Liked: 3 times
Joined: Mar 05, 2019 3:29 pm
Full Name: Tim Lawhead
Contact:

Re: Enumerate files in a backup repository - with no backup job/.vbm file

Post by TimLawhead »

Oleg,

Thank you for that pathway.

I am getting an error with the .NET call.

PS C:\> [Veeam.Backup.Core.CRepositoryAccessorFactory]

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False CRepositoryAccessorFactory System.Object

PS C:\> [Veeam.Backup.Core.CRepositoryAccessorFactory]::Create($repository)
Cannot find an overload for "Create" and the argument count: "1".
At line:1 char:1
+ [Veeam.Backup.Core.CRepositoryAccessorFactory]::Create($repository)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest


I did find a way that should work, but it will require more manual steps. Support pointed out that you can go to the Files section highlight the orphaned files in the HPE StoreOnce repository directory and copy/paste the names into a text file editor and then use those names in a PowerShell script to pull them in. For some reason, the console on my workstation in 9.5 U4 and now 10 CU2 won't let me copy and paste from the Files section into anything. After Support said that, I remoted into the the VBR server and using the console there it let me get the file names via Copy/Paste. Not sure what the issue is my my workstation console, but it was something I tried to do back in the beginning of this issue and was disappointed it wasn't a feature...only to find out later it is and there's a bug with my workstation.

I like the idea of handling the import all via a script and have little experience with the .NET methods. A quick search didn't turn up any documentation for Veeam .NET scripts or Veeam .NET methods. Any suggestions on how/where to learn these?

jhoughes
Veeam Software
Posts: 190
Liked: 60 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Austin, TX
Contact:

Re: Enumerate files in a backup repository - with no backup job/.vbm file

Post by jhoughes »

You won't find much specific around Veeam for the .NET types/methods, as it is unsupported & undocumented, and most users don't need functionality beyond the native PowerShell cmdlets.

I've got code and a demo of exporting details of the Veeam types & methods in my upcoming VeeamON session, as the session is focused around a PowerShell deep dive for reporting & configuration. Even my demos & code do not cover details about how to use the methods, since that requires understanding more advanced PowerShell, sometimes some .NET, and working with overloads.

Plus, since it's all core PowerShell functionality and understanding .NET, there is lots of documentation around how to work with it online.
Husband, Father, Solutions Architect, Geek Extraordinaire | @AustinVMUG & @ATXPowerShell leader | VMUG US South Regional Champion | VMware vExpert | Cisco Champion

oleg.feoktistov
Veeam Software
Posts: 391
Liked: 125 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Enumerate files in a backup repository - with no backup job/.vbm file

Post by oleg.feoktistov »

Hey Tim,

Code: Select all

[Veeam.Backup.Core.CRepositoryAccessorFactory]::Create($repository)
Cannot find an overload for "Create" and the argument count: "1".
At line:1 char:1
+ [Veeam.Backup.Core.CRepositoryAccessorFactory]::Create($repository)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
Make sure to pass exactly one StoreOnce repository to the method arguments.

Thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests