Creating VBM from scratch

PowerShell script exchange

Creating VBM from scratch

Veeam Logoby DiscusSystems » Tue Feb 11, 2014 7:40 am

Hello All,

Can anyone help me with re-creating our VBM files using the powerscript from VpowerCLI? (http://www.vpowercli.co.uk/2011/12/29/c ... m-scratch/)

I appreciate this isn't a Veeam product however after speaking to support yesterday they have told me that we cannot recover from our backups unless we have a valid VBM file.

I have a number of monthly drives which we copy VBK files off to, we also have a few associated VBM files however a few of these files (VBM) have been removed from the drive and therefore we cannot restore.

When trying to import the backup file (VBM) to the script GUI from VpowerCLI I receive an error;

Code: Select all
PS C:\Users\*username*> C:\Users\*username*\Desktop\VeeamPSSnapIn.ps1

GAC    Version        Location
---    -------        --------
True   v4.0.30319     C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Wind...
Cannot convert argument "0", with value: "System.Object[]", for "GenerateMeta"
to type "Veeam.Backup.Core.CBackup": "Cannot convert the "System.Object[]" valu
e of type "System.Object[]" to type "Veeam.Backup.Core.CBackup"."
At C:\Users\*username*\Desktop\VeeamPSSnapIn.ps1:43 char:71
+         $Data = [Veeam.Backup.Core.CBackupMetaGenerator]::GenerateMeta <<<< (
$Backup)
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument

You cannot call a method on a null-valued expression.
At C:\Users\*username*\Desktop\VeeamPSSnapIn.ps1:44 char:24
+         $Data.Serialize <<<< () | Out-File $VBMFile
    + CategoryInfo          : InvalidOperation: (Serialize:String) [], Runtime
   Exception
    + FullyQualifiedErrorId : InvokeMethodOnNull

Exception calling "Load" with "1" argument(s): "Could not find file '\\192.168.
200.217\share\Non-Critical\Non-Critical Backup.vbm'."
At C:\Users\*username*\Desktop\VeeamPSSnapIn.ps1:46 char:18
+         $xml.Load <<<< ($VBMFile)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

Property 'JobName' cannot be found on this object; make sure it exists and is s
ettable.
At C:\Users\*username*\Desktop\VeeamPSSnapIn.ps1:47 char:25
+         $xml.BackupMeta. <<<< JobName = $JobName
    + CategoryInfo          : InvalidOperation: (JobName:String) [], RuntimeEx
   ception
    + FullyQualifiedErrorId : PropertyNotFound

Exception calling "Save" with "1" argument(s): "Invalid XML document. The docum
ent does not have a root element."
At C:\Users\*username*\Desktop\VeeamPSSnapIn.ps1:48 char:18
+         $xml.Save <<<< ($VBMFile)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

New-Object : Cannot find type [Veeam.Backup.Core.CBackupRepositoryImporter]: ma
ke sure the assembly containing this type is loaded.
At C:\Users\*username*\Desktop\VeeamPSSnapIn.ps1:53 char:37
+         $TempRepository = New-Object <<<<  Veeam.Backup.Core.CBackupRepositor
yImporter -ArgumentList $Repository, 0
    + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentExcepti
   on
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewOb
   jectCommand

You cannot call a method on a null-valued expression.
At C:\Users\*username*\Desktop\VeeamPSSnapIn.ps1:54 char:31
+         $TempRepository.Import <<<< ()
    + CategoryInfo          : InvalidOperation: (Import:String) [], RuntimeExc
   eption
    + FullyQualifiedErrorId : InvokeMethodOnNull


Can anyone advise of what we can do to get around this issue?

many thanks
Discus
DiscusSystems
Novice
 
Posts: 3
Liked: never
Joined: Tue Feb 11, 2014 7:12 am
Full Name: Damien Biddulph

Re: Creating VBM from scratch

Veeam Logoby v.Eremin » Tue Feb 11, 2014 9:23 am

They have told me that we cannot recover from our backups unless we have a valid VBM file.

Hmmm, actually, as long as, you have full backup file, it can be imported to the backup console, and you will be able to restore either files or VMs from it. May I ask you to provide your ticket number here?

Anyway, you can try to import corresponding full backup to backup console and see whether it helps or not. It can be done by right-clicking "Backups" node -> Import backup -> backup file.

Thanks,
v.Eremin
Veeam Software
 
Posts: 13534
Liked: 1002 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Creating VBM from scratch

Veeam Logoby tsightler » Tue Feb 11, 2014 1:12 pm

Indeed, having a VBM file is not required to be able to restore files or VMs, as a matter of fact, the script referenced above, as well as the one that I post below, use this fact to create VBM files from scratch. For my simple script below you use the Veeam GUI to import the VBK, set the variables in the script (backup name) and the run it. It uses an internal function call to create the VBM XML data, make a minor modification to the JobName and then writes it the data out to the VBM. If you have only the VBK file you must use the "Import" button to browse and locate the VBK file and have it imported into Veeam, but it should work with no problem.

Creating a VBM can sometimes be useful. One common use for me is to create a seed for backup copy jobs from a "normal" backup chain. Normally a backup copy job must be seeded from a single restore points/VBK file which prevents you from using an existing backup chain for a seed since these almost always have multiple chains, however, using this script you can grab just the most recent VBK from an existing backup chain, import it, run the script to create a VBM, and then combine them to use as a seed for a BCJ.

Anyway, just in case it is needed here is the script that I use to create VBM files from scratch. It's basically a modified versions of the script referenced above, but much simpler as I removed the GUI and the automatic import of the VBK, you can just use the Veeam GUI for those steps. The script creates the VBM file on the current users Desktop, but that's easy to change to any path. After running the script you can place the VBK and the newly created VBM file in any repository. Since it now has an appropriate VBM file a simple rescan of the repo will cause it to show up in the GUI and it can now be used for mapping backup or backup copy jobs.

Code: Select all
asnp "VeeamPSSnapIn" -ErrorAction SilentlyContinue

$BackupName = "<Name of Imported Backup>"
$Backup = Get-VBRBackup -Name ($BackupName + "_imported")
$VBMFile = "$env:UserProfile\Desktop\" + "$BackupName" + ".vbm"

$Data = [Veeam.Backup.Core.CBackupMetaGenerator]::GenerateMeta($Backup)
$Data.Serialize() | Out-File $VBMFile
$xml = New-Object XML
$xml.Load($VBMFile)
$xml.BackupMeta.JobName = $BackupName
$xml.Save($VBMFile)
Remove-VBRBackup -Backup $Backup -Confirm:$false
tsightler
Veeam Software
 
Posts: 4834
Liked: 1785 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Re: Creating VBM from scratch

Veeam Logoby DiscusSystems » Tue Feb 11, 2014 1:56 pm

v.Eremin wrote:
They have told me that we cannot recover from our backups unless we have a valid VBM file.

Hmmm, actually, as long as, you have full backup file, it can be imported to the backup console, and you will be able to restore either files or VMs from it. May I ask you to provide your ticket number here?

Anyway, you can try to import corresponding full backup to backup console and see whether it helps or not. It can be done by right-clicking "Backups" node -> Import backup -> backup file.

Thanks,


Case 00511507 [ ref:_00D30RWR._50060Wm0W9:ref ]

The file will not import into the backup console using the import feature.. it seems to appear to have worked then nothing appears in the imported backups. When we spoke to Veeam support they said that without a valid VBM file we could not import.
DiscusSystems
Novice
 
Posts: 3
Liked: never
Joined: Tue Feb 11, 2014 7:12 am
Full Name: Damien Biddulph

Re: Creating VBM from scratch

Veeam Logoby v.Eremin » Tue Feb 11, 2014 3:01 pm

In order to be completely sure - What is the type of the file you're trying to import?

I've taken a brief look at your case, and it seems to be concerned mostly with .vrb file, not .vbm one.

Here's a summary of our webex session with your colleague: we added the shared folder with backups as a repository and imported the backup successfuly. However, from the imported .vbk you are able to restore only to the most recent state. If you want to restore to a previous point in time, you need to have a corresponding .vrb (rollback) file in the same folder.


Thanks.
v.Eremin
Veeam Software
 
Posts: 13534
Liked: 1002 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Creating VBM from scratch

Veeam Logoby DiscusSystems » Tue Feb 11, 2014 3:27 pm

Ok... Can someone please call me so we can discuss this on the phone instead?
DiscusSystems
Novice
 
Posts: 3
Liked: never
Joined: Tue Feb 11, 2014 7:12 am
Full Name: Damien Biddulph

Re: Creating VBM from scratch

Veeam Logoby v.Eremin » Tue Feb 11, 2014 3:41 pm

You can clarify the situation regarding "import" functionality with the support team within the existing case.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13534
Liked: 1002 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Creating VBM from scratch

Veeam Logoby nathanael.duke » Mon Aug 11, 2014 10:47 pm 1 person likes this post

I've seen this powershell script around. Posting it here for informational purposes.

Code: Select all
Add-PsSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue
[reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
#Textfield Progress
$Progress = New-Object Windows.Forms.Label
$Progress.Text = "Progress: None"
$Progress.Location = New-Object Drawing.Point 64, 50
$Progress.Size = New-Object Drawing.Point 200, 100
 
#Button Setup
$Button = New-Object Windows.Forms.Button
$Button.text = "Import"
$Button.Location = New-Object Drawing.Point 65, 25
 
$Button.add_click(
{
    #Open Dialog Setup
    $Dialog = New-Object Windows.Forms.OpenFileDialog
    $Dialog.InitialDirectory = "C:\\"
    $Dialog.Filter = "VBK Files (*.vbk)|*.vbk"
    $Dialog.ShowHelp = $true
    $Dialog.ShowDialog()
    $Dialog.FileName -match "(?:.*\\)+(.+?)\d\d\d\d-\d\d-\d\dT\d\d\d\d\d\d\.vbk"
 
    #Veeam Setup
    $JobName = $Matches[1]
    $VeeamBox = Get-VBRLocalhost
    $Progress.Text = "Progress: Importing Backup"
    $FileName = $Dialog.FileName
    $Path = [System.IO.Path]::GetDirectoryName($Dialog.FileName)
    $VBMFile = $Path + "\" + $JobName + ".vbm"
    if(!([System.IO.File]::Exists($VBMFile)))
    {
        if(!(Get-VBRBackup -Name $JobName))
        {
            Import-VBRBackup -Server $VeeamBox -FileName $FileName
            $Backup = Get-VBRBackup -Name ($JobName + "_imported")
        }
        else
        {
            $Backup = Get-VBRBackup -Name $JobName
        }
        $Progress.Text = "Progress: Creating VBM File"
        $Data = [Veeam.Backup.Core.CBackupMetaGenerator]::GenerateMeta($Backup)
        $Data.Serialize() | Out-File $VBMFile
        $xml = New-Object XML
        $xml.Load($VBMFile)
        $xml.BackupMeta.JobName = $JobName
        $xml.Save($VBMFile)
        $Progress.Text = "Progress: Clean Up"
        Remove-VBRBackup -Backup $Backup -Confirm:$false
        $Progress.Text = "Progress: Repo Discovery"
        $Repository = Get-VBRBackupRepository | ?{$_.path -eq $Path}
        $TempRepository = New-Object Veeam.Backup.Core.CBackupRepositoryImporter -ArgumentList $Repository, 0
        $TempRepository.Import()
        $Progress.Text = "Progress: Finished"
 
    }
    else
    {
        $Progress.Text = "Failed: VBM Exists"
    }
})
 
#Form Setup
$Form = New-Object Windows.Forms.Form
$Form.Size = New-Object Drawing.Point 220,100
$Form.Text = "VBM Create"
$Form.Controls.Add($Button)
$Form.Controls.Add($Progress)
$Form.FormBorderStyle = "FixedDialog"
$Form.MaximizeBox = $false;
$Form.ShowDialog()
nathanael.duke
Veeam Software
 
Posts: 10
Liked: 3 times
Joined: Mon Apr 28, 2014 4:28 pm
Full Name: Nathanael JonCroft Duke

Re: Creating VBM from scratch

Veeam Logoby ThomasMc » Sat Aug 23, 2014 10:35 am

No real point in c&p the script as he linked to it already and if you must, at least give Seth some credit ;)
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: Creating VBM from scratch

Veeam Logoby hdang » Tue Mar 31, 2015 4:38 pm

Hi,
When I tried to runt he script I get an error.

PS C:\Users\*****> $Data = [Veeam.Backup.Core.CBackupMetaGenerator]::GenerateMet
a($Backup)
Exception calling "GenerateMeta" with "1" argument(s): "Full storage not found"
At line:1 char:1
+ $Data = [Veeam.Backup.Core.CBackupMetaGenerator]::GenerateMeta($Backup)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : Exception

Any suggestion? I should also note that I tried this on another backup chain and it worked. Not sure what is causing this to failed.
hdang
Novice
 
Posts: 3
Liked: never
Joined: Tue Mar 31, 2015 4:35 pm
Full Name: Henry Dang

Re: Creating VBM from scratch

Veeam Logoby v.Eremin » Tue Mar 31, 2015 5:18 pm

Hi, Henry, which product version you're trying the script at? Is it version 8, by any chance?

If so, please, open a ticket with our support team, they have a script for re-creating .vbm file which is compatible with version 8. Once the case is opened, kindly, provide its number here, so that, I can follow it.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13534
Liked: 1002 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Creating VBM from scratch

Veeam Logoby hdang » Tue Mar 31, 2015 6:28 pm

Hi,
No it is not version 8. We are still on version 7, but have plans to upgrade to version 8 in the near future.
I'm not sure why the script is not working for this job as it did for another. I do have a case open, though, the support personnel said you guys don't provide the script nor they can re-create the .vbm file...

Case #00867329
hdang
Novice
 
Posts: 3
Liked: never
Joined: Tue Mar 31, 2015 4:35 pm
Full Name: Henry Dang

Re: Creating VBM from scratch

Veeam Logoby v.Eremin » Wed Apr 01, 2015 12:06 pm

Thank you for posting your ticket number. I'll see what can be done in this regard and update the topic, once I have more information.
v.Eremin
Veeam Software
 
Posts: 13534
Liked: 1002 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Creating VBM from scratch

Veeam Logoby v.Eremin » Wed Apr 01, 2015 3:14 pm

For version 7 the script provided here should work fine. So, I'm not sure why it's not working on a particular job.

Anyway, we've contacted your support engineer and make him aware of existence of scripts for version 8; will see what happens next.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13534
Liked: 1002 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Creating VBM from scratch

Veeam Logoby tsightler » Wed Apr 01, 2015 3:26 pm

For version 7 the script provided here should work fine. So, I'm not sure why it's not working on a particular job.

Which is just a reposting of my version of this script (based heavily on Seth's original) from a few post up in this thread.
tsightler
Veeam Software
 
Posts: 4834
Liked: 1785 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Next

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 8 guests