PowerShell script exchange
jozne
Influencer
Posts: 17
Liked: 7 times
Joined: Apr 18, 2012 6:55 pm
Full Name: Jari Haikonen
Contact:

Start-VBRWindowsFileRestore

Post by jozne » Dec 16, 2014 4:28 pm

I updated veeam to v8 and the example in http://helpcenter.veeam.com/backup/80/p ... files.html does not seem to work anymore. I have not run the jobs with the new v8 version yet.

$result seems to be missing MountSession and I can not retrieve the FLR mountpoint.

Code: Select all

PS C:\scripts> $result | gm


   TypeName: Veeam.Backup.PowerShell.Model.FileRestore

Name         MemberType Definition
----         ---------- ----------
Dispose      Method     System.Void Dispose()
Equals       Method     bool Equals(System.Object obj)
GetHashCode  Method     int GetHashCode()
GetType      Method     type GetType()
ToString     Method     string ToString()
CreationTime Property   System.DateTime CreationTime {get;}
Drives       Property   System.String Drives {get;}
Id           Property   System.Guid Id {get;}
MountPoint   Property   System.String MountPoint {get;}
Oib          Property   Veeam.Backup.Core.COib Oib {get;}
Size         Property   System.String Size {get;}
VmName       Property   System.String VmName {get;}


PS C:\scripts> $result | Format-List
Id           : 164731f8-5dbc-47a1-b1b4-f155066243c8
MountPoint   : C
Drives       : C:\VeeamFLR\dc1\Volume0, C:\VeeamFLR\dc1\Volume1, C:\VeeamFLR\dc
               1\Volume2
VmName       : dc1
Size         : 1,2 TB
CreationTime : 16.12.2014 1:32:27
Oib          : Veeam.Backup.Core.COib

veremin
Product Manager
Posts: 16710
Liked: 1396 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRWindowsFileRestore

Post by veremin » Dec 17, 2014 12:27 pm

How many disks does the said VM have? And from which one you're trying to restore? In case of source disk being C:, the following script might allow you to achieve what you're after:

Code: Select all

asnp VeeamPSSnapin
$result = Get-VBRBackup | where {$_.jobname -eq "Name of your Job"} | Get-VBRRestorePoint | where {$_.name -eq "Name of your VM"} | Sort-Object creationtime -Descending | Select-Object -First 1 | Start-VBRWindowsFileRestore
$Files = "File or folder to restore"
$RestoreDestination = "Folder to which file or folder should be restored"
$File = $Result.Drives.Substring($Result.Drives.LastIndexOf(" ")).substring(1) + (split-path -NoQualifier $Files)
Copy $File $RestoreDestination -Force -Recurse
Stop-VBRWindowsFileRestore $Result
Thanks.

jozne
Influencer
Posts: 17
Liked: 7 times
Joined: Apr 18, 2012 6:55 pm
Full Name: Jari Haikonen
Contact:

Re: Start-VBRWindowsFileRestore

Post by jozne » Dec 17, 2014 12:39 pm

I'll be using the script for number of VMs with different number of disks and I cannot be sure which Volume1-X is the correct one
for example E-Drive -> hence I tried finding the correct FLR mountpoint by using the provided example in documentation.

But since it does not provide MountSession property I could not. Your example would work if the number of disks etc. would
remain the same.

jozne
Influencer
Posts: 17
Liked: 7 times
Joined: Apr 18, 2012 6:55 pm
Full Name: Jari Haikonen
Contact:

Re: Start-VBRWindowsFileRestore

Post by jozne » Dec 17, 2014 12:46 pm

I think I'll quickly "bypass" this problem by using test-path for all the volumeX FLR paths...

veremin
Product Manager
Posts: 16710
Liked: 1396 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRWindowsFileRestore

Post by veremin » Dec 17, 2014 12:53 pm

Using Test-Path method in order to get an appropriate drive might do the trick. As to missing MountSession parameter, we're currently investigating this situation (whether the parameter can be brought back).Thanks.

jozne
Influencer
Posts: 17
Liked: 7 times
Joined: Apr 18, 2012 6:55 pm
Full Name: Jari Haikonen
Contact:

Re: Start-VBRWindowsFileRestore

Post by jozne » Dec 17, 2014 1:02 pm 1 person likes this post

For reference, changes my apply (depending your settings)

Code: Select all

asnp -Name VeeamPSSnapin -ErrorAction SilentlyContinue
$computer = "computer"
$origfile = "folder"
$restoreto = "restoreto"
$result = Get-VBRBackup | where {$_.jobname -eq "$computer"} | Get-VBRRestorePoint | where {$_.name -eq "$computer"} | Sort-Object creationtime -Descending | Select-Object -First 1 |Start-VBRWindowsFileRestore

$folders = gci "c:\veeamflr\$computer" | select-object FullName
foreach($folder in $folders){ 
if(Test-Path ($folder.fullname +(Split-Path -NoQualifier $origfile))) {
$file = ($folder.fullname +(Split-Path -NoQualifier $origfile))
Copy-Item $file $restoreto -recurse
}
}
Stop-VBRWindowsFileRestore $result

AdrianHinton
Enthusiast
Posts: 71
Liked: 6 times
Joined: Apr 07, 2014 10:00 am
Full Name: Adrian Hinton
Contact:

[MERGED] : Get-VBRRestorePoint in Version 8, patch 1

Post by AdrianHinton » Jan 19, 2015 5:04 am

Hi,

Has anything changed with what is returned in Get-VBRRestorePoint since V8? I have the following script that gets all my copy jobs and does an FLR on the most recent log file in C:\Windows\Logs in the backup but it isnt working anymore:

Code: Select all

$Backups = $Null

$Backups = Get-VBRBackup | ?{$_.IsBackupSync -eq $true -and $_.Name -ne 'Normal-ServerName - Copy'}

Foreach($Backup in $Backups){

try{


$LogString = $Null
$WFLR = $null

$WFLR = Get-VBRBackup -Name $Backup.name | Get-VBRRestorePoint  |
Sort CreationTime -Descending | Select -First 1 | Start-VBRWindowsFileRestore

$WFLR.MountSession.MountedDevices.mountpoint[0] | % {

    
    LogWrite "Started Veeam File Level Restore on $($Backup.name)"

    $File = GCI C:\Windows\Logs -Recurse | 
    Sort LastwriteTime | 
    Select -Last 1 | 
    ? {$_.PsIsContainor -ne $true} 
    
    LogWrite "Found $($File.FullName)"

    if((Test-Path "C:\VeeamRestores\$($Backup.Name)\$(Get-Date -Format 'yyyyMMdd')_Restore\") -eq $false){

        New-Item "C:\VeeamRestores\$($Backup.Name)\$(Get-Date -Format 'yyyyMMdd')_Restore\" -ItemType Directory

        Logwrite "Created directory C:\VeeamRestores\$($Backup.Name)\$(Get-Date -Format 'yyyyMMdd')_Restore\ "

    }
     
    Copy-Item $File.FullName -Destination "C:\VeeamRestores\$($Backup.Name)\$(Get-Date -Format 'yyyyMMdd')_Restore\"
    
    if(Test-Path "C:\VeeamRestores\$($Backup.Name)\$(Get-Date -Format 'yyyyMMdd')_Restore\$($File.Name)"){

        LogWrite "Successfully copied $($File.Name) to C:\VeeamRestores\$($Backup.Name)\$(Get-Date -Format 'yyyyMMdd')_Restore\" 

        }
    
    }

Stop-VBRWindowsFileRestore $WFLR

}

Catch [system.exception]{

    Logwrite " ERROR: $($Error[0].exception.message) against $($Backup.name) "

  }
}
This line here is not returning anything where previously it did:

Code: Select all

$WFLR.MountSession.MountedDevices.mountpoint[0]
And I have checked the members of the $WFLR variable and there is no such member named Mountsession. But this was working before the upgrade to V8.

veremin
Product Manager
Posts: 16710
Liked: 1396 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRWindowsFileRestore

Post by veremin » Jan 19, 2015 9:39 am

The internal structure of the said object has changed, indeed. You might want to apply the described changes to make the script work. Thanks.

Tim783
Influencer
Posts: 13
Liked: never
Joined: Jul 20, 2012 2:05 pm
Contact:

Re: Start-VBRWindowsFileRestore

Post by Tim783 » Jan 21, 2015 4:22 pm

v.Eremin wrote:How many disks does the said VM have? And from which one you're trying to restore? In case of source disk being C:, the following script might allow you to achieve what you're after:

Code: Select all

asnp VeeamPSSnapin
$result = Get-VBRBackup | where {$_.jobname -eq "Name of your Job"} | Get-VBRRestorePoint | where {$_.name -eq "Name of your VM"} | Sort-Object creationtime -Descending | Select-Object -First 1 | Start-VBRWindowsFileRestore
$Files = "File or folder to restore"
$RestoreDestination = "Folder to which file or folder should be restored"
$File = $Result.Drives.Substring($Result.Drives.LastIndexOf(" ")).substring(1) + (split-path -NoQualifier $Files)
Copy $File $RestoreDestination -Force -Recurse
Stop-VBRWindowsFileRestore $Result
Thanks.
Hi Eremin,

I have been trying to get your script working but am having a few problems I am hoping you might be able to help me with.

For some reason the volume mapping is not working. The script always looks in Volume6 (in the Veeam FLR folder) when the file is not actually on this volume. Because of this the script fails

Code: Select all

Copy : Cannot find path 'C:\VeeamFLR\VMNAME\Volume6\MSSQL\DATA\OnlinePayments.mdf' because it does not exist.
At line:1 char:1
+ Copy $File $RestoreDestination -Force -Recurse
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\VeeamFLR\INV...inePayments.mdf:String) [Copy-Item], ItemNotFoundExce
   ption
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand
Any ideas why this is happening?

Thanks

AdrianHinton
Enthusiast
Posts: 71
Liked: 6 times
Joined: Apr 07, 2014 10:00 am
Full Name: Adrian Hinton
Contact:

Re: Start-VBRWindowsFileRestore

Post by AdrianHinton » Jan 21, 2015 11:44 pm

More breakage. Is there a page which shows all the changes to Powershell cmdlets, methods and outputs?

Code: Select all

Function Import-SingleBackup{

param(
    [Parameter(Mandatory=$True,Position=1)]
    [String]$ServerName
)


Add-PSSnapin VeeamPSSnapin

$VBRServer = Get-VBRServer | where {$_.Type -eq "Local"}
$DirectoryVBMs = Get-ChildItem "D:\Backups\*.vbm" -Recurse | %{$_.FullName}
$SelectedBackup = $DirectoryVBMs | ?{$_ -like "*$($ServerName)*"}


Import-vbrbackup -server $VBRServer -FileName $SelectedBackup
}

Function Import-AllBackups{

Add-PSSnapin VeeamPSSnapin

$VBRServer = Get-VBRServer | where {$_.Type -eq "Local"}
$DirectoryVBMs = Get-ChildItem "D:\Backups\*.vbm" -Recurse | %{$_.FullName} 

foreach($VBM in $DirectoryVBMs){
    
    Import-vbrbackup -server $VBRServer -FileName $VBM
    }
    
}

veremin
Product Manager
Posts: 16710
Liked: 1396 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRWindowsFileRestore

Post by veremin » Jan 22, 2015 11:49 am

Hey, Tim,

Have you tried to use the updated script provided by Jari?

Thanks.

Tim783
Influencer
Posts: 13
Liked: never
Joined: Jul 20, 2012 2:05 pm
Contact:

Re: Start-VBRWindowsFileRestore

Post by Tim783 » Jan 22, 2015 1:30 pm

Hi Eremin,

Just tried Jari's script,but get the following error

Code: Select all

gci : Cannot find path 'C:\veeamflr\INVGSYVMSQLPR01' because it does not exist.
At C:\Users\thardwickadm\Desktop\test.ps1:7 char:12
+ $folders = gci "c:\veeamflr\$computer" | select-object FullName
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\veeamflr\INVGSYVMSQLPR01:String) [Get-ChildItem], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
 
Stop-VBRWindowsFileRestore : Cannot validate argument on parameter 'FileRestore'. The argument is null. Provide a valid value for the argument, and then try running the command again.
At C:\Users\thardwickadm\Desktop\test.ps1:14 char:28
+ Stop-VBRWindowsFileRestore $result
+                            ~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Stop-VBRWindowsFileRestore], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Command.StopVBRWindowsFileRestore
Am I doing something wrong?
Thanks

AdrianHinton
Enthusiast
Posts: 71
Liked: 6 times
Joined: Apr 07, 2014 10:00 am
Full Name: Adrian Hinton
Contact:

Re: Start-VBRWindowsFileRestore

Post by AdrianHinton » Feb 17, 2015 12:11 am

Hi,

Any answers? A page with all the changes after V8 so us scripters can easily fix all the problems V8 has introduced?
AdrianHinton wrote:More breakage. Is there a page which shows all the changes to Powershell cmdlets, methods and outputs?

Code: Select all

Function Import-SingleBackup{

param(
    [Parameter(Mandatory=$True,Position=1)]
    [String]$ServerName
)


Add-PSSnapin VeeamPSSnapin

$VBRServer = Get-VBRServer | where {$_.Type -eq "Local"}
$DirectoryVBMs = Get-ChildItem "D:\Backups\*.vbm" -Recurse | %{$_.FullName}
$SelectedBackup = $DirectoryVBMs | ?{$_ -like "*$($ServerName)*"}


Import-vbrbackup -server $VBRServer -FileName $SelectedBackup
}

Function Import-AllBackups{

Add-PSSnapin VeeamPSSnapin

$VBRServer = Get-VBRServer | where {$_.Type -eq "Local"}
$DirectoryVBMs = Get-ChildItem "D:\Backups\*.vbm" -Recurse | %{$_.FullName} 

foreach($VBM in $DirectoryVBMs){
    
    Import-vbrbackup -server $VBRServer -FileName $VBM
    }
    
}

veremin
Product Manager
Posts: 16710
Liked: 1396 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRWindowsFileRestore

Post by veremin » Feb 17, 2015 11:13 am

Chances are, the mountsession parameter will be added back in patch 2 or a bit later.

As to listing all of changes introduced, you can refer to the corresponding section of help center for more information about new commandlets. The problem is that some custom scripts utilize internal methods or properties that are being modified on regular basis (product patch, release, etc.), and it's almost impossible to track those.

Thanks.

AdrianHinton
Enthusiast
Posts: 71
Liked: 6 times
Joined: Apr 07, 2014 10:00 am
Full Name: Adrian Hinton
Contact:

Re: Start-VBRWindowsFileRestore

Post by AdrianHinton » Feb 23, 2015 3:53 am

v.Eremin wrote:Chances are, the mountsession parameter will be added back in patch 2 or a bit later.

As to listing all of changes introduced, you can refer to the corresponding section of help center for more information about new commandlets. The problem is that some custom scripts utilize internal methods or properties that are being modified on regular basis (product patch, release, etc.), and it's almost impossible to track those.

Thanks.
Some notice would be nice. Considering Veeam was touted as being the backup solution that we could automate with powershell, I find it distressing at the very least that Veeam will go ahead and change powershell cmdlets, members or methods without first showing a front and centre stage *WARNING* about the changes.

I had a working script that would mount each backup of a windows server, search that backup for the latest log file and copy that log file out to a dir before unmounting and moving off to the next one. This satisfied the business that backups are OK each month. The business requires this and now I can't seem to use the code you have provided to do the same thing. Just as I figured it out, Veeam go and remove it. Why? I don't get it. IT JUST WORKS!

veremin
Product Manager
Posts: 16710
Liked: 1396 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRWindowsFileRestore

Post by veremin » Feb 24, 2015 12:39 pm

As I've said, the change related to mountsession was unintentional. We do consider that as a bug, and are going to fix it soon.

The other changes apply either to tape commandlets or to some internal methods or properties.

Tape PS model has been revised seriously in version 8 due to incompleteness of its predecessor. As the result, some of the commandlets have been changed slightly, new properties have been added, etc. However, those changes are covered in details in the corresponding User Guide.

As to the second category, there are "creative" scripts that are making use of hidden or internal properties, accessing those by loading assembly and so on. Quite naturally, those scripts are not officially supported. Moreover, those properties and methods are being changed regularly (patch, release) and we don't keep track of that.

Hope it makes sense.
Thanks.

lycanwrath
Novice
Posts: 4
Liked: never
Joined: Jun 28, 2012 10:29 am
Full Name: Naif Sheik Hoossain
Contact:

[MERGED] : Restore a specific folder to a windows share

Post by lycanwrath » Mar 16, 2015 5:22 am

Hello,

I am trying to create a restore VM (HyperV) folder to a windows share test job and would very much appreciate if someone can point me in the right direction to do this.

Regards,
Naif

lycanwrath
Novice
Posts: 4
Liked: never
Joined: Jun 28, 2012 10:29 am
Full Name: Naif Sheik Hoossain
Contact:

Re: Start-VBRWindowsFileRestore

Post by lycanwrath » Mar 16, 2015 7:00 am

Hello,

Thanks for this script ,I managed to run it script successfully, is there a way to view/output the log of the restore process from this script?

Regards,
Naif

veremin
Product Manager
Posts: 16710
Liked: 1396 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRWindowsFileRestore

Post by veremin » Mar 16, 2015 9:21 am

Your post has been merged into existing discussion, your initial topic has been deleted, as per your request.

As to progress bar, you might consider usage of Write-Progress commandlet in combination with Copy-Item. Take a look at some approaches people use in the wild: Progress bar for copied files in powershell, Copy-ItemWithProgress.

Thanks.

lycanwrath
Novice
Posts: 4
Liked: never
Joined: Jun 28, 2012 10:29 am
Full Name: Naif Sheik Hoossain
Contact:

Re: Start-VBRWindowsFileRestore

Post by lycanwrath » Mar 16, 2015 11:13 am

v.Eremin wrote:Your post has been merged into existing discussion, your initial topic has been deleted, as per your request.

As to progress bar, you might consider usage of Write-Progress commandlet in combination with Copy-Item. Take a look at some approaches people use in the wild: Progress bar for copied files in powershell, Copy-ItemWithProgress.

Thanks.
Hello,

I am not talking about progress bar but rather about a log file (e.g. restorelog.txt) containing info about the restore process (whether it has completed, which errors if any, files copied, etc..)
Grateful if someone can help.

veremin
Product Manager
Posts: 16710
Liked: 1396 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRWindowsFileRestore

Post by veremin » Mar 16, 2015 11:16 am

What about using -ErrorVariable parameter to write errors to a variable and, then, copy the content of the variable to a text file?

lycanwrath
Novice
Posts: 4
Liked: never
Joined: Jun 28, 2012 10:29 am
Full Name: Naif Sheik Hoossain
Contact:

Re: Start-VBRWindowsFileRestore

Post by lycanwrath » Mar 25, 2015 8:36 am

v.Eremin wrote:What about using -ErrorVariable parameter to write errors to a variable and, then, copy the content of the variable to a text file?
Thank you very much, script is all good now :)

veremin
Product Manager
Posts: 16710
Liked: 1396 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRWindowsFileRestore

Post by veremin » Mar 25, 2015 10:20 am

You're welcome. If other help is needed, feel free to contact us.

JMorseMarco
Novice
Posts: 6
Liked: 1 time
Joined: Aug 28, 2015 9:54 pm
Full Name: Justin Morse
Contact:

Re: Start-VBRWindowsFileRestore

Post by JMorseMarco » Sep 02, 2015 7:20 pm

I've got my script created, however it fails instantly with the below error. I've tried a mixture of various scripts on the Forum, and one of them kind of worked, but it doesn't scan all the volumes for the file. I'm not familiar with PS at all, so any help would be greatly appreciated.

Error upon running script:

Code: Select all

Get-ChildItem : Cannot find path 'C:\veeamflr\KANETREXCH01' because it does not exist.
At C:\Users\justin.morse\desktop\RestoreScript.ps1:5 char:15
+ $folders = gci <<<<  "c:\veeamflr\$computer" | select-object FullName
    + CategoryInfo          : ObjectNotFound: (C:\veeamflr\KANETREXCH01:String) [Get-ChildItem], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

Stop-VBRWindowsFileRestore : Cannot validate argument on parameter 'FileRestore'. The argument is null. Supply a non-nu
ll argument and try the command again.
At C:\Users\justin.morse\desktop\RestoreScript.ps1:12 char:27
+ Stop-VBRWindowsFileRestore <<<<  $result
    + CategoryInfo          : InvalidData: (:) [Stop-VBRWindowsFileRestore], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Command.StopVBRWindowsFileResto
   re
This is the Script that errors out:

Code: Select all

$computer = "KANETREXCH01"
$origfile = "_Marco"
$restoreto = "E:\Kane Transport\KANETREXCH01"
$result = Get-VBRBackup | where {$_.jobname -eq "$computer"} | Get-VBRRestorePoint | where {$_.name -eq "$computer"}| Where-Object {$_.CreationTime -like "*8/24/2015*"} | Select-Object -First 1 | Start-VBRWindowsFileRestore
$folders = gci "c:\veeamflr\$computer" | select-object FullName
foreach($folder in $folders){ 
if(Test-Path ($folder.fullname +(Split-Path -NoQualifier $origfile))) {
$file = ($folder.fullname +(Split-Path -NoQualifier $origfile))
Copy-Item $file $restoreto -Force -Recurse 
}
}
Stop-VBRWindowsFileRestore $result 
This is the script that actually works, but it doesn't scan all the volumes:

Code: Select all

#$result = Get-VBRBackup | where {$_.jobname -eq "MMC-KANETR"} | Get-VBRRestorePoint | where {$_.name -eq "KANETREXCH01"} | Where-Object {$_.CreationTime -like "*8/25/2015*"} | Select-Object  -First 1 | Start-VBRWindowsFileRestore
#$Files = "\_Marco"
#$RestoreDestination = "E:\Kane Transport\KANETREXCH01"
#$File = $Result.Drives.Substring($Result.Drives.LastIndexOf(" ")).substring(1) + (split-path -NoQualifier $Files)
#Copy $File $RestoreDestination -Force -Recurse
#Stop-VBRWindowsFileRestore $Result

veremin
Product Manager
Posts: 16710
Liked: 1396 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRWindowsFileRestore

Post by veremin » Sep 03, 2015 12:13 pm

Does the given directory exist on that machine? (C:\VeeamFLR) Doesn't your repository have a different directory specified as NFS folder by any chance?

JMorseMarco
Novice
Posts: 6
Liked: 1 time
Joined: Aug 28, 2015 9:54 pm
Full Name: Justin Morse
Contact:

Re: Start-VBRWindowsFileRestore

Post by JMorseMarco » Sep 03, 2015 2:41 pm 1 person likes this post

I actually figured this out last night after some screwing around. My initial $Result wasn't working correctly, so there was essentially nothing to copy. Once I figured that out it was smooth sailing. So essentially, this version contains a specific Date from the restore point and grabs the first one, you can modify the Date, or create a new variable. Then it scans all the mount points for the specified source, lastly it copies the source to the destination. Confirmed working with Veeam 8.x

Code: Select all

$computer = "SERVER"
$jobname = "JOBNAME"
$origfile = "\PATH TO ORIGINAL FILE"
$restoreto = "DRIVE:\PATH TO FILE"
$result = Get-VBRBackup | where {$_.jobname -eq "$jobname"} | Get-VBRRestorePoint | where {$_.name -eq "$computer"}| Where-Object {$_.CreationTime -like "*8/24/2015*"} | Select-Object -First 1 | Start-VBRWindowsFileRestore 

$folders = gci "c:\veeamflr\$computer" | select-object FullName
foreach($folder in $folders){ 
if(Test-Path ($folder.fullname +(Split-Path -NoQualifier $origfile))) {
$file = ($folder.fullname +(Split-Path -NoQualifier $origfile))
Copy-Item $file $restoreto -Recurse 
}
}
Stop-VBRWindowsFileRestore $result 

veremin
Product Manager
Posts: 16710
Liked: 1396 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRWindowsFileRestore

Post by veremin » Sep 03, 2015 6:23 pm

Yep, as long as there is no WinFLR session present, the corresponding folder (C:\VeeamFLR) contains nothing. Thus, the failure you've come across while trying to copy something from it.

Glad to hear that you've nailed it.

Thanks.

JMorseMarco
Novice
Posts: 6
Liked: 1 time
Joined: Aug 28, 2015 9:54 pm
Full Name: Justin Morse
Contact:

Re: Start-VBRWindowsFileRestore

Post by JMorseMarco » Sep 16, 2015 9:33 pm

I'm very short on time, otherwise I'd spend more time testing before posting this question. I'm actually in the middle of a very large restore of Production Data, and I have a very tight deadline. Is there a way to restore the specified file back to the Live VM? If I go through the gui, it allows me to Restore > Overwrite. How can I perform that trick using the Script?

The first part of the script above grabs the restore point, but instead of scanning the Volumes and copying the file to E:\ on the Veeam Server, how can I just copy it to the Root of C:\ on the original VM?

Any help would be greatly appreciated, even some direction as I can't find much on restoring to the Original VM ironically.

Sincerely,
Justin

veremin
Product Manager
Posts: 16710
Liked: 1396 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRWindowsFileRestore

Post by veremin » Sep 17, 2015 12:55 pm

You should make Copy-Item commandlet copy required file(s) to a different machine either using administrative share or creating a new PS drive. Thanks.

JMorseMarco
Novice
Posts: 6
Liked: 1 time
Joined: Aug 28, 2015 9:54 pm
Full Name: Justin Morse
Contact:

Re: Start-VBRWindowsFileRestore

Post by JMorseMarco » Sep 18, 2015 4:24 pm

Thank you for the response, however that is not possible. There are about 30 Clients and about 100+ Servers I believe. Each Client is on their own network in vCenter, there is no access to any admin shares directly from the Veeam Server. However, when restoring from the GUI you can perform restores back to the VM. Is there no way to perform this same operation using Powershell?

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests