Solved

Vmware server 2 - Automated Snapshots & Backup

Posted on 2011-09-20
16
867 Views
Last Modified: 2012-05-12
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?
0
Comment
Question by:aacrz
  • 10
  • 4
  • 2
16 Comments
 
LVL 117
ID: 36568761
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
 
LVL 117
ID: 36568777
(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
 
LVL 40

Expert Comment

by:coolsport00
ID: 36568789
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
 
LVL 117
ID: 36568793
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
 
LVL 40

Expert Comment

by:coolsport00
ID: 36568798
Ha...and there you go; learn something new everyday! :) (#3)
0
 
LVL 117
ID: 36568822
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
 
LVL 117
ID: 36568832
Please note, VMware Workstation and VMware Server share similar technologies, and the same concepts and tech works for both.
0
 

Author Comment

by:aacrz
ID: 36569156
what is the snapshot command? I am only interested in that and not backing up the whole vm.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 117
ID: 36569183
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
 
LVL 117
ID: 36569189
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
 
LVL 117
ID: 36569284
Is your goal to Backup the VM automatically?
0
 

Author Comment

by:aacrz
ID: 36569298
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
 
LVL 117
ID: 36569431
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
 

Author Comment

by:aacrz
ID: 36569567
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
 
LVL 117

Accepted Solution

by:
Andrew Hancock (VMware vExpert / EE MVE) earned 500 total points
ID: 36569664
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
 

Author Closing Comment

by:aacrz
ID: 36573831
I will start another question for snapshot backup
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article will show you how to create an ISO CD-ROM/DVD-ROM image (*.iso), and MD5 checksum signature, for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5). It's a good idea to compare checksums, because many installations fail because of a corr…
In this step by step tutorial with screenshots, we will show you HOW TO: Enable SSH Remote Access on a VMware vSphere Hypervisor 6.5 (ESXi 6.5). This is important if you need to enable SSH remote access for additional troubleshooting of the ESXi hos…
Teach the user how to edit .vmx files to add advanced configuration options Open vSphere Web Client: Edit Settings for a VM: Choose VM Options -> Advanced: Add Configuration Parameters:
This video shows you how easy it is to boot from ISO images for virtual machines with the ISO images stored on a local datastore on the ESXi host.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now