PowerShell script exchange
Post Reply
IonutN
Novice
Posts: 4
Liked: 1 time
Joined: Sep 25, 2014 8:57 am
Full Name: Ionut Nica
Contact:

Add-VBRCopyJob - how to properly specify target as datastore

Post by IonutN »

Hi,

I am trying to write a set of commands that will create a lab environment from a number of VMs. The VMs need to be copied as is from a vCenter to the same vcenter, but other datastores, or to different vCenters alltogether.
For simplicity the code below just copies the VMs to another datastore on a specific host in the same vcenter.
This lab will be needed to be created on demand, so i chose to automate this using Veeam PowerShell snapin.

Code: Select all

$vcenter = "demo-vcenter"
$EntityToCopy = Find-VBRViEntity -Name "VM1" -VMsAndTemplates -Server $vcenter 
$sourceServer = Get-VBRServer -Type VC -name $vcenter

$server = Get-VBRServer -Type ESXi -name "ESX01.demo" 

$viableDS = Find-VBRViDatastore -Server $server | ? {$_.FreeSpace -gt $EntityToCopy.ProvisionedSize } | sort FreeSpace -Descending | select -First 1

Add-VBRCopyJob -Name "VM1-To-Sandbox" -Type VDDK -Server $server -folder $viableDS -SourceServer $sourceServer -Objects $EntityToCopy.Name -Description "test" -Verbose
And i get this error

Code: Select all

Add-VBRCopyJob : Use File type to create FileCopy job
At line:1 char:1
I don't want to use the file parameter for this, since it will create a file copy job.
My guess is that I'm specifying the folder parameter wrong, but I don't know how to properly code it.
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Add-VBRCopyJob - how to properly specify target as datas

Post by veremin »

Try to disregard -folder parameter completely, as it makes commandlet believe that you're about to create file copy job.

Alternative way to create exact copy of VM might be restoring VM from a backup or replicating source VM.

Thanks.
alin
Novice
Posts: 3
Liked: never
Joined: Aug 30, 2018 3:11 pm
Full Name: Alin Grecea
Contact:

Re: Add-VBRCopyJob - how to properly specify target as datastore

Post by alin »

I have one question about this as well.

I want to copy existing full backups from my repository to lets say another location be it anything.

I have been looking trough the veeam commands, and I couldn't quite figure it out if I can copy existing backups.

Is that possible?
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Add-VBRCopyJob - how to properly specify target as datastore

Post by veremin »

The recommended approach is to create a backup copy job. It allows you to archive existing backups to secondary backup repositories.

If that does not work for you for some reason, then, just script activity of a copy utility of your choice - robocopy or similar.

Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests