In the powerclibook I found the backup-vm function very useful (chapter 10 )
I do not post the direct link to the function because I am not sure if this is allowed.
You will find the function if you follow http://www.powerclibook.com/
I wonder if this function could be modified to backup several vms that are part of an Vapp.
Thanks for helping.
regards
Andreas
Hi Andreas, no problem mentioning the link since we already published it as well in our PowerCLI Book: Download Scripts, Functions and Modules post.
Concerning your question, you could try something like this
Get-VM -Location (Get-vApp -Name MyvApp) | %{
Backup-VM -VM $_ -Datastore (Get-Datastore MyDS
)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Andreas, no problem mentioning the link since we already published it as well in our PowerCLI Book: Download Scripts, Functions and Modules post.
Concerning your question, you could try something like this
Get-VM -Location (Get-vApp -Name MyvApp) | %{
Backup-VM -VM $_ -Datastore (Get-Datastore MyDS
)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
thanks for feedback. I already tested this before posting and received the same issue.
Date: VM-004 Backing up
Date: VM-004 Creating Snapshot
Date: VM-004 Cloning from snapshot to VM-004-2011041909
Ausnahme beim Aufrufen von "CloneVM" mit 3 Argument(en): "folder"
(Translation: Error on calling "CloneVM" with 3 Arguments")
Bei C:\skripte\vmware\vm\backupvm.ps1:74 Zeichen:33
+ $CreateClone = $vmView.CloneVM <<<< ( $cloneFolder, $CloneVM, $cloneSpec )
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
regards
Andreas
Also checked the following but the issue remaines:
http://communities.vmware.com/thread/306247
http://www.simonlong.co.uk/blog/2010/05/05/powercli-a-simple-vm-backup-script/
My workarround for the moment is:
Get-VM -Location (Get-vApp -Name myVapp) | ForEach-Object {
$VM = $_
Move-VM $_ -Destination Ressourcepool
Backup-VM -VM (get-VM $_) -Datastore (Get-Datastore "Lun0")
Move-VM $_ -Destination myVapp }
My issue is solved.
Instead of using
$cloneFolder = $vmView.parent
I used:
$clonefolder = (Get-Folder -Name "myfolder" | Get-View).MoRef
This is also described here: http://communities.vmware.com/thread/276353
regards Andreas
Hi Luc,
I am using the backup-vm script (without the vapp feature) now at least since 6 month for weekly backups and it works very good.
The backup process takes unfortunately hours because there is no "parallel processing feature" implemented. It snapshots one vm after the other.
I know that there are some vcenter limitations regarding snapshots, storage vmotion etc.
Is there a way to overcome this. In an ideal case it would be nice if I could backup at least 4 vms at once.
Thanks for helping.
regards
Andreas
to be more precise
I'm looking for something similar like the $maxtask example (executing multiple clonevm tasks)
http://www.mbn-bs.co.uk/blog/2010/08/updated-powercli-vmware-vm-backup-script-v2-0/
regards
Andreas