PowerShell script exchange
Post Reply
claudio.rigolio
Novice
Posts: 9
Liked: never
Joined: Mar 15, 2017 8:49 am
Full Name: Claudio Rigolio
Contact:

Restore vmdk from cloud to specific VM on datastore

Post by claudio.rigolio »

Hi,
I'm writing a script for automatic restore of entire VMs from my cloud backup but I have some copy job only for single vmdk for space saving.
I can't figure out how to create restore procedure for theese vmk directly into VMs datastore position.

If I use the GUI it works correctly.

My script is this one:

Code: Select all

Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue
Get-VBRBackupRepository -Name "NAME" | Sync-VBRBackupRepository
$lastdb1 = Get-VBRBackup -Name "DB1 Cloud" | Get-VBRRestorePoint -Name *DB1* | Select -Last 1
$drhost = Get-VBRServer -Name "IP-ADDRESS"
$drdatastore = Find-VBRViDatastore -Server $drhost -Name "DATASTORE-NAME"

$xmlpath = "<datacenterRef></datacenterRef><datacenterName></datacenterName><datacenterPath></datacenterPath><hostRef>HOST-IP</hostRef><datastoreRef>DATASTORE-GUID</datastoreRef><datastoreGuid>DATASTORE-GUID</datastoreGuid><FullName>[DRdatastore] DB1/TEST/DB1_4.vmdk</FullName>"

$virtualDisk = Get-VBRFilesInRestorePoint -RestorePoint $lastdb1 | where {$_.FileName -like “*DB1_4*”}

Start-VBRRestoreVMFiles –RestorePoint $lastdb1 –Server $drhost -path $xmlpath -Files $virtualDisk
What is the correct "-path" for Start-VBRRestoreVMFiles procedure?
Thanks in advanced for your help.
Bye

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

Re: Restore vmdk from cloud to specific VM on datastore

Post by veremin »

I'm not sure whether an XML path can be used as a target destination. You might want to try some local path first (such as D:\temp) to confirm this assumption. Thanks.
claudio.rigolio
Novice
Posts: 9
Liked: never
Joined: Mar 15, 2017 8:49 am
Full Name: Claudio Rigolio
Contact:

Re: Restore vmdk from cloud to specific VM on datastore

Post by claudio.rigolio »

With local path it works correctly, but I need to write directly into my datastore, under VM folder, like the GUI does.
I tried with datastore path from vSphere Clinet like "[datastore]/APP1", or "/vmfs/volumes/577d00d0-0fe5abb0-9756-ac254f58df7c" but it doesn't work and it gives me an "XML path error", that's why I'm trying xml path.
I looked veeam logs and there I found the xml path that I'm trying to use.
veremin
Product Manager
Posts: 20406
Liked: 2299 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Restore vmdk from cloud to specific VM on datastore

Post by veremin »

Most likely, the said parameter expects a local path, not a path to a datastore. So, in your case, it should be two-step process: restore to local path and copy it later to datastore via copy utility. Thanks.
claudio.rigolio
Novice
Posts: 9
Liked: never
Joined: Mar 15, 2017 8:49 am
Full Name: Claudio Rigolio
Contact:

Re: Restore vmdk from cloud to specific VM on datastore

Post by claudio.rigolio »

It means that the GUI does the direct restore to datastore but the powershell doesn't?
It's a bit strange....
I thought that all GUI procedures were powershell command...
Am I wrong?

Thanks
tsightler
VP, Product Management
Posts: 6035
Liked: 2860 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Restore vmdk from cloud to specific VM on datastore

Post by tsightler »

The GUI is definitely not using Powershell behind the scenes. Our Powershell cmdlets are quite functional and provide probably 80-90% of the GUI functionality, but not quite everything.
Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests