Start-VBRWindowsFileRestore

PowerShell script exchange

Re: Start-VBRWindowsFileRestore

Veeam Logoby v.Eremin » Tue 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.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

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

Veeam Logoby lycanwrath » Mon 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: Thu Jun 28, 2012 10:29 am
Full Name: Naif Sheik Hoossain

Re: Start-VBRWindowsFileRestore

Veeam Logoby lycanwrath » Mon 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
lycanwrath
Novice
 
Posts: 4
Liked: never
Joined: Thu Jun 28, 2012 10:29 am
Full Name: Naif Sheik Hoossain

Re: Start-VBRWindowsFileRestore

Veeam Logoby v.Eremin » Mon 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.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Start-VBRWindowsFileRestore

Veeam Logoby lycanwrath » Mon 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.
lycanwrath
Novice
 
Posts: 4
Liked: never
Joined: Thu Jun 28, 2012 10:29 am
Full Name: Naif Sheik Hoossain

Re: Start-VBRWindowsFileRestore

Veeam Logoby v.Eremin » Mon 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?
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Start-VBRWindowsFileRestore

Veeam Logoby lycanwrath » Wed 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 :)
lycanwrath
Novice
 
Posts: 4
Liked: never
Joined: Thu Jun 28, 2012 10:29 am
Full Name: Naif Sheik Hoossain

Re: Start-VBRWindowsFileRestore

Veeam Logoby v.Eremin » Wed Mar 25, 2015 10:20 am

You're welcome. If other help is needed, feel free to contact us.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Start-VBRWindowsFileRestore

Veeam Logoby JMorseMarco » Wed 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
JMorseMarco
Novice
 
Posts: 6
Liked: 1 time
Joined: Fri Aug 28, 2015 9:54 pm
Full Name: Justin Morse

Re: Start-VBRWindowsFileRestore

Veeam Logoby v.Eremin » Thu 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?
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Start-VBRWindowsFileRestore

Veeam Logoby JMorseMarco » Thu 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
JMorseMarco
Novice
 
Posts: 6
Liked: 1 time
Joined: Fri Aug 28, 2015 9:54 pm
Full Name: Justin Morse

Re: Start-VBRWindowsFileRestore

Veeam Logoby v.Eremin » Thu 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.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Start-VBRWindowsFileRestore

Veeam Logoby JMorseMarco » Wed 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
JMorseMarco
Novice
 
Posts: 6
Liked: 1 time
Joined: Fri Aug 28, 2015 9:54 pm
Full Name: Justin Morse

Re: Start-VBRWindowsFileRestore

Veeam Logoby v.Eremin » Thu 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.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Start-VBRWindowsFileRestore

Veeam Logoby JMorseMarco » Fri 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?
JMorseMarco
Novice
 
Posts: 6
Liked: 1 time
Joined: Fri Aug 28, 2015 9:54 pm
Full Name: Justin Morse

PreviousNext

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 10 guests