VMware Cloud Community
jidar
Contributor
Contributor

Pre / Post scripts for Snapshots

VMwareTools-7303-158874 / Most up to date version for 3.5u4-ish

Located in /usr/sbin

-rwxrwxrwx 1 root root 47 Dec 22 16:50 post-thaw-script.sh

-rwxrwxrwx 1 root root 46 Dec 22 16:49 pre-freeze-script.sh

The contents of the scripts:

#!/bin/sh

sleep 30

/bin/touch /tmp/foo

exit 0

I've tried renaming the scripts to FREEZE, pre-freeze.sh, pre-freeze-script, pre-freeze.

The same with post. I've tried putting the files in /etc/vmware-tools.

Nothing I seem to do works.

The guest VM is CentOS 5.2

My testing method is to issue a snapshot without memory from the VIC, or the vimsh command that is related to creating a snapshot.

I am not using VCB for this test.

0 Kudos
5 Replies
lamw
Community Manager
Community Manager

I don't know if this is possible w/o VCB being installed, I think the functionality of calling these freeze/thaw scripts is a feature of VCB running and you can either use canned scripts or write your own which are executed on behalf of VMware Tools via VCB during/after the backup process. I don't know if you can have it execute other wise.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
admin
Immortal
Immortal

According to http://www.vmware.com/pdf/vi3_35/esx_3/r35u2/vi3_35_25_u2_vm_backup.pdf page 52, the scripts need to be:

/usr/sbin/pre-freeze-script
/usr/sbin/post-thaw-script

Also, you need to make sure to specify the "Quiesced" option when taking the snapshot.

jidar
Contributor
Contributor

There wasn't any option for Quiesced from the GUI for 3.5u4, so I hit up the vmware-cmd and found a way to do it from there, and then couldn't find a way to do it from vimsh.

/usr/bin/vmware-cmd createsnapshot TestSnapShot "A test for snapshots!" 1 0

works and,

vimsh:

$ vmsvc/snapshot.create

Insufficient arguments.

Usage: snapshot.create vmid snapshotName snapshotDescription includeMemory

Doesn't have the option at all. So this is poor design if you ask me, but oh wel.

0 Kudos
lamw
Community Manager
Community Manager

Yea the extra quiesce parameter was fixed in ESX(i) 4.0 for vimsh ... but then again vimsh is not officially supported, you can't really complain too much Smiley Wink

Though the quiesce option has been supported in VI 3.5 via the API, probably just not ported down to the CLI and as you know it's also in the vmware-cmd when issuing snapshot.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
lamw
Community Manager
Community Manager

This is interesting point .... so can we say that if you have take a snapshot with quiesce option selected AND if you have two scripts within the guestOS named:

/usr/sbin/pre-freeze-script
/usr/sbin/post-thaw-script

that prior to the snapshot, pre-freeze-script will be executed and before the snapshot is committed that post-thaw-script will be executed? and it doesn't care what is within those scripts?

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos