VMware Cloud Community
andreasbrunner
Contributor
Contributor
Jump to solution

Backup VM function for VMs that are part of an Vapp

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

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

Reply
0 Kudos
7 Replies
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
andreasbrunner
Contributor
Contributor
Jump to solution

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

Reply
0 Kudos
andreasbrunner
Contributor
Contributor
Jump to solution

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 }

Reply
0 Kudos
andreasbrunner
Contributor
Contributor
Jump to solution

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

Reply
0 Kudos
andreasbrunner
Contributor
Contributor
Jump to solution

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

Reply
0 Kudos
andreasbrunner
Contributor
Contributor
Jump to solution

to be more precise Smiley Happy

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

Reply
0 Kudos