Vmware server 2 - Automated Snapshots & Backup

First.
Please only respond if you have done this on a vmware server 2, as other technologies are different.

1. What files = snapshot?
2. What is the best way to take snapshots (guest on, or off?)
2. How to automate the snapshot process?
aacrzAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Andrew Hancock (VMware vExpert / EE MVE^2)Connect With a Mentor VMware and Virtualization ConsultantCommented:
1. Quite simply to Backup, Shutdown the VM, Copy the Folder, Start the VM.
2. Do NOT keep your VMs, running in Snapshot Mode, it's not supported long term, performance is poor, you will run it issues, when you run out of disk space.

Use Snapshots, when you need to make changes to your VMs, e.g. patching, if patching has been successful, Delete the Snapshot, if patching has failed Revert.

A. No, because your Snapshot file is out of date, from the moment you have copied it, and turned on the machine, it's useless. With a huge amount of "hacking" it may be possible to merge an old out of date snapshot and virtual disk machine, but I would only ever attempt this, as a last resort.

When you are in "snapshot mode", the main virtual disk is no longer written to. All changes are written to the snapshot file only, from the moment you have created the snapshot. The snapshot file cannot be copied whilst the VM is on. But you can copy the main virtual disk file. (because it is no longer written to, so it has no machine lock on the file).

Both Virtual Disk Main file + Snapshot file are required to start the VM. If the snapshot file is not available ALL the changes since the machine was put "into snapshot mode" will be lost.

If you were to restore an older Snapshot file, the pointers would be mismatched, and you would not be able to merge or start the VM.

If the snapshot was not available, all the changes would be lost.

B. what is the process of snapshots on a datastore?
That's off topic in this post and is another question, it's beyond the scope of this question.
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
A snapshot is NOT a backup of a VM; that is a gross misconception.  

A snap shot is a way to preserve a point in time when the VM was running OK before making changes. A snapshot is NOT a way to get a static copy of a VM before making changes.  When you take a snapshot of a VM what happens is that a delta file gets created and the original VMDK file gets converted to a Read-Only file.  There is an active link between the original VMDK file and the new delta file.  Anything that gets written to the VM actually gets written to the delta file.   The correct way to use a snapshot is when you want to make some change to a VM like adding a new app or a patch; something that might damage the guest OS. After you apply the patch or make the change and it’s stable, you should really go into snapshot manager and delete the snapshot which will commit the changes to the original VM, delete the snap, and make the VMDK file RW. The official stance is that you really shouldn’t have more than one snap at a time and that you should not leave them out there for long periods of time. Adding more snaps and leaving them there a long time degrades the performance of the VM.  If the patch or whatever goes badly or for some reason you need to get back to the original unmodified VM, that’s possible as well.  

I highly recommend reading these 2 articles on VMware Virtual Machine Snapshots:

Understanding Snapshots - http://kb.vmware.com/kb/1015180
Snaphot Best Practices - http://kb.vmware.com/kb/1025279

Also check out the following Snapshot Articles by Eric Siebert

Pt.1- http://is.gd/Lajg4p
Pt.2- http://is.gd/NdKQWC
Pt.3- http://is.gd/tp2vEK
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
(the vmrun command is the same for VMware Workstation and VMware Server 2.0)

To automate the snapshot process you would use the vmrun command.

See the manual here
http://www.vmware.com/pdf/vix160_vmrun_command.pdf

Snapshot Commands

Create a snapshot of a virtual machine with VMware Workstation on a host :

vmrun -T ws snapshot /path/to/vm/Ubuntu/Ubuntu.vmx mySnapshot

List snapshots on the virtual machine, showing the one just made:

vmrun -T ws listSnapshots /path/to/vm/Ubuntu/Ubuntu.vmx

Total snapshots: 1

mySnapshot

Revert to the snapshot just made, which suspends the virtual machine, and resume operation:

vmrun -T ws revertToSnapshot /path/to/vm/Ubuntu/Ubuntu.vmx mySnapshot

vmrun -T ws start /path/to/vm/Ubuntu/Ubuntu.vmx

Delete the snapshot, specifying it by name:

vmrun -T ws deleteSnapshot /path/to/vm/Ubuntu/Ubuntu.vmx mySnapshot
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
coolsport00Commented:
1. Snapshot files are "delta" files in the VM folder, designated as .000x.vmdk usually.
2. There is no 'best way' really to take a snap; you can do either way with no disruption to the VM
3. There is no way that I'm aware of to automate snapshotting on VMware Server. For more on snapshots with VMware Server, see:
http://www.vmware.com/pdf/vmserver2.pdf, pg. 195, as well as the docs provided by @hanccocka above.

~coolsport00
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
1. Backup the VMDK files only, not the files with -000001.vmdk etc these are the snapshot files. (and cannot be backed up whilst the VM is on)

2. Guest On or Off does not matter. (although if the VM is off, you can backup all the VMDK files).

3. use a batch files or cmd file, that's run from the Windows scheduler, using commands as detailed above to create the snapshot or power off the machine, and copy the files.

when in snapshot mode, you will be able to copy the main vmdk files
0
 
coolsport00Commented:
Ha...and there you go; learn something new everyday! :) (#3)
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
This is an EXAMPLE script, which will shutdown the VM, copy the VM, and start the VM.

 
C:
REM Change to VM Directory

CD "C:\Documents and Settings\<user>\My Documents\My Virtual Machines\WinXP\WinXP.vmx"

REM Shutdown VM

"C:\Program Files\VMware Workstation\vmrun" stop "C:\Documents and Settings\<user>\My Documents\My Virtual Machines\WinXP\WinXP.vmx" -soft

REM Copy VM to network share

Copy *.* \\server\backup

REM Startup VM

"C:\Program Files\VMware Workstation\vmrun" start "C:\Documents and Settings\<user>\My Documents\My Virtual Machines\WinXP\WinXP.vmx"

Open in new window


You can do similar with snapshot command if you wish.
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
Please note, VMware Workstation and VMware Server share similar technologies, and the same concepts and tech works for both.
0
 
aacrzAuthor Commented:
what is the snapshot command? I am only interested in that and not backing up the whole vm.
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
The snapshot is not a backup!

you cannot copy the snapshot file!

Snapshot Commands

Create a snapshot of a virtual machine with VMware Workstation on a host :

vmrun -T ws snapshot /path/to/vm/Ubuntu/Ubuntu.vmx mySnapshot

List snapshots on the virtual machine, showing the one just made:

vmrun -T ws listSnapshots /path/to/vm/Ubuntu/Ubuntu.vmx

Total snapshots: 1

mySnapshot

Revert to the snapshot just made, which suspends the virtual machine, and resume operation:

vmrun -T ws revertToSnapshot /path/to/vm/Ubuntu/Ubuntu.vmx mySnapshot

vmrun -T ws start /path/to/vm/Ubuntu/Ubuntu.vmx

Delete the snapshot, specifying it by name:

vmrun -T ws deleteSnapshot /path/to/vm/Ubuntu/Ubuntu.vmx mySnapshot
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
okay power off the VM, but what will you do with the snapshot file?

its not a backup of the vm! you also need the main vmdk?
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
Is your goal to Backup the VM automatically?
0
 
aacrzAuthor Commented:
okay,  here is what I have done.
Backed up the whole folder of VM so C:\Virtual Machines\VMGUEST  
No, I just Want to take snapshots weekly, and back up that Snapshot file only to my network location.  This is so in case, something happens, I can revert to my snapshot.

You mention that it does not matter to snapshot file wether VM is on or off, so it does not matter to me.  I would rather have a process that works!
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
You cannot copy a snapshot file to a network location, and then put if back and revert to it.

The snapshot file and main virtual machine virtual disk file are linked. The moment, you copy the snapshot file to another location, whilst the machine is off, the moment you power the Machine backon, the snapshot file will be out of date, rendering the copied snapshot file invalid.

All you can do is Backup the whole folder.

Virtual Machine Snapshots do not work like, what you are wanting to do. If you want to complete Weekly snapshots of a Virtual Machine use a Datastore, that is Snapshot aware, Snapshots of the datastore can be taken of the VM, which are indepedant of the VM.

You should not run on a Snapshot, just use Snapshots for Patching, so you can revert the snapshot if there is an issue.
0
 
aacrzAuthor Commented:
So, lets say

A.

1. I had a snapshot file localL
2. A backup copy.

if the local copy was corrupted, I couldn't just replace with a Network copy (mirror?).

B. what is the process of snapshots on a datastore?
0
 
aacrzAuthor Commented:
I will start another question for snapshot backup
0
All Courses

From novice to tech pro — start learning today.