Link to home
Start Free TrialLog in
Avatar of ShopLiftin
ShopLiftin

asked on

How can I script/automate VMWare backups to disk (NFS)?

Ok, I am trying to get a full handle on the VMWare thing and have 3 VM Host servers up and running and using Virtual Center etc.  It's quite nice.

I want to backup to disk cheaply, so I thought FreeNAS would be perfect for this, so I setup a cheap FreeNAS box, from parts test with.  I have attached the FreeNAS as a DataStore on each of my VM Host servers, now...here's the question.

How can I automate VMDK backups to the NFS datastore?  I've been reading so much VCB documentation that my head hurts.  Any ideas?

Also, I'm excellent with MS products, my *NIX skills are just so-so - mainly rusty from the old days.

Thanks!!

Chris
Avatar of kumarnirmal
kumarnirmal
Flag of India image

I suggest that you take a look at this product - http://www.trilead.com/Products/VM_Explorer/
Avatar of Luciano Patrão
Hi

You can use VCB, or other scripts to backup your VMware

For VCB checj this article

http://searchvmware.techtarget.com/tip/0,289483,sid179_gci1277118_mem1,00.html?track=sy421

Examples of scripts backup, and very easy to work with.

http://engineering.xtravirt.com/products/phd-technologies/visbu.html

and

http://www.vmts.net/vmbk.htm

Jail
Avatar of markzz
markzz

Before suggesting a backup method or what you are asking for is a scripted routine could you explain what type of VM licensing you have.
Quite simply put, if you are licensed for VCB you should leverage of it.
Its a very powerful tool. Of course you can backup to OPenfiler or OPenNAS.
In VM there is much more to consider than just backing up..I guess where most go wrong is they can't successfully recover.
Avatar of ShopLiftin

ASKER

Ok,  I guess more detail is needed here.

I have 3 VM Hosts using a Macromedia Flex license server on a Virtual Center Server.  I also do have VCB licensing on each host server.  All 3 VM Hosts attach via 2 GB Ethernet connections to an EMC Celerra NS20 on a separate VLAN using NFS.  I only have 5 VM's per host for load balancing and DR purposes.

I am currently using Symantec Backup Exec (I'm still on 11d) also running on the VC Server attached to a LTO3 Tape Library.

I backup the data using Symantex BE via agents on the member servers.

What I am asking here, is can I ALSO backup the VMDK's to disk, possibly once or twice a week to a NAS server, ie, a FreeNAS setup, with 5 X 1.5TB SATA Drives so that in the event of a disaster on the EMC Celerra end, I could run critical servers also via NFS off of the FreeNAS box while repairing the Celerra.

So the idea would be that I could recover servers quickly on an alternate NFS (because ideally I would have separate copies of the VMDK's that I could start from)...then I could recover up to date data files from the LTO3's.  Make sense so far?

I have created a test FreeNAS box with the 5 X 1.5TB drives and I'm getting 5.45TB useable space.  I have the FreeNAS on the VLAN and added to each VM host as another datastore called "nas1".  (Also, I built this 7TB total - 5.45TB in RAID5 FreeNAS box for less than $800 using an ASUS mobo with 5 SATA ports, a ThermalTake Case + PS, a LV Sempron Processor, 2GB Patriot RAM and an Intel NIC, the SeaGates were only $76 each, I installed FreeNAS to a $6 USB Stick)

I can't believe that there aren't just straightforward ways to do snapshots to an alternate datastore.

Markzz:  I hope I've provided enough info, because I was reading a 28 page VMWare communities board on the topic and it was making me ill, and it was also unfinished and recently posted to...

Kumar and BestWay, I'm looking into those links now.

-Chris
There are a number of methods to copy a VM, but to copy them while they are running is not such a simple task.
I guess one of my concerns is if you head down a particular direction like I did then realise you just don't have the comprehensive skills to support a routine written in a Lunix envronment, it can be such an enormous waste of time and resources.
I would encourage you to firstly leverage your VCB lincenses to ensure you have complete and recoverable backups.
Regarding the question of getting a copy to another VMFS store I'd suggest the simplest routine would be to perform a scheduled Clone.
It's very simple to setup a Schedule via the VC, one of the options is to performa a clone. These can be done live if you are on 3.5u2 or higher.
There's always a catch. If you don't want multiple version on disk you will beed to kick of a script to delete you previous clone. Pretty straight forward realy, I would do this from your VC via the remote CLI.

As I say this is still quite an untidy routine by my way of thinking. There are other alternatives but they all cost $$
I'd suggest you also look at vRanger (esx Ranger) it's a very easy and comprehensive backup and restore routine and can perform backups at a block level so you are only moving changed blocks, it also has VCB type backup functionallity but again effectively giving you incremental backups. Lets not get into the incremental verse full backup methods, I'm just highlighting the functions.
To start with.
Have a fiddle with the VC's Scheduling functions if your happy with that then have a read about the remote CLI.
There are esx specific CLI commands to remove and manipulate your vmdk's but as these systems are not powered on I expect the conventional Linux Commands will be fine
eg. cd to your VMFS
rm -rf /foldername
 
To add a little more
I have tested some of the alternative solutions. eg, VM Explorer, FastSCP, WinSCP.
I use WinSCP and FastSCP for moving small amounts of data to and from the ESX servers.
An example of the expected performance.
I can backup a running guest of 150GB with VCB in about 75 minutes. I tried the same thing with VM Explorer it took 48 hours. Or FastSCP took 12 hours. It's far to add that VCB's in my case are over 4Gb FC where as the other mentioned routines were of course over the network at 100Mb.
It's best to do your own testing but the point here is although there are many possible backup or replication routines few are robust enough or fast enough to implement into a production environment.
Ok, I'm looking Markzz here, and I'll give it a go.

I'm not completely useless with Linux, I'm just rusty.  I was only making comment that backing up files on VMWare was not finalized yet.  No open file option just exists in the system.  Storing changes in a delta file while the copy takes place, that sort of thing.

Mark, let me try scheduling the deletion of clones using the RCLI and scheduling the cloning of VMs.

This sounds like a great option, I'll post back here later today.

Chris
Markzz,

I get the error when I run the scheduled clone, "The attempted operation cannot be performed in the current state (Powered On)."

Ok, I have looked into Perl a little bit and using the RCLI scripts isn't looking so difficult.

I have actually tried someone elses script but they (the automated ones) don't account for a couple of things, such as:
  1. VM Names with spaces in them.
  2. VM Configurations with VMDK's on different datastores.

I am creating/tweaking a script not that will backup a SINGLE VM - with or without spaces
- You can specify the name of each VMDK and the datastore that it resides in.

It will create a snap shot, delete the exisiting copy, create a new copy, and then delete the snap.

The modifications are done in variables at the top.  I will post the script tomorrow or Thursday after I've tested.

Chris
ASKER CERTIFIED SOLUTION
Avatar of ShopLiftin
ShopLiftin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also, the script that BestWay pointed out did not run and backup my VM's, mainly because of the issues that I wrote into the solution script, spaced in folder names, VMDKs spread across datastores, etc.