Platespin sample freeze and thaw scripts for Linux workload targets

  • 7010555
  • 01-Aug-2012
  • 18-Sep-2012

Environment

NetIQ PlateSpin Protect 10.2

Situation

For Linux systems, PlateSpin Protect provides you with the capability to automatically execute custom scripts (freeze and thaw) that complement the automatic daemon control feature. Freeze is executed at the beginning of a replication, and thaw is executed at the end of a replication. Consider using this capability to complement the automated daemon control feature provided through the user interface.

 

For example, you might want to use this feature to temporarily freeze certain daemons instead of shutting them down during replications.

 

Resolution

To implement the feature, use the following procedure before setting up your Linux workload protection:  

1. Create the following files:

 

·          platespin.freeze.sh: A shell script to execute at the beginning of the replication

·          platespin.thaw.sh: A shell script to execute at the end of the replication

·          platespin.conf: A text file defining any required arguments, along with a timeout value.

 

The required syntax for the contents of the platespin.conf file is:

 

[ServiceControl]
FreezeArguments=<arguments>
ThawArguments=<arguments>
Timeout=<timeout>

 

Replace <arguments> with the required command arguments, separated by a space, and <timeout> with a timeout value in seconds. If a value is not specified, the default timeout is used (60 seconds).

 

2. Save the scripts, along with the .conf file, on your Linux source workload, in the following directory:

 

/etc/platespin

Note: See additional information section for sample scripts.

Additional Information

Sample Freeze Script:

#!/bin/bash

###############################################################################
# File: platespin.freeze.sh
# Copy this file to /etc/platespin/platespin.freeze.sh on the Linux source
workload.
###############################################################################

# Sample script to flush and lock the mysql database tables.
# This scripts works with the /etc/platespin/platespin.thaw.sh script.

FREEZE_DONE_FLAG=/tmp/platespin.freeze.done
THAW_DONE_FLAG=/tmp/platespin.thaw.done

# Clean up the flag files, just in case
[ -e $FREEZE_DONE_FLAG ] && rm -f $FREEZE_DONE_FLAG
[ -e $THAW_DONE_FLAG ] && rm -f $THAW_DONE_FLAG

# Run the mysql script to flush all the tables and logs on this server.
# This SQL script MUST be run in background and it will not return until
# platespin.thaw.sh is called.
/usr/bin/mysql -B -u root <<-EOF &
  Flush tables with Read Lock;
  Flush Logs;

  # Signal platespin.freeze.sh the database freezing job is done.
  system touch $FREEZE_DONE_FLAG

  # Wait until platespin.thaw.sh is called, which means the database
  # can be unlocked.
  delimiter :
  system while [ ! -e $THAW_DONE_FLAG ]; do sleep 1; done
  delimiter ;
  system rm -f $THAW_DONE_FLAG
  Unlock tables;
EOF

# Check if the database has been frozen.
# Since the above SQL script is running in the backgroud, we cannot exit until
# the database freeze and flush action has completed. The SQL script will
# touch the flag file /tmp/platespin.freeze.done.
while [ ! -e $FREEZE_DONE_FLAG ]; do
  sleep 1;
done
rm -f $FREEZE_DONE_FLAG

exit 0
 
 
Sample Thaw Script:
 
#!/bin/sh

###############################################################################
# File: platespin.thaw.sh
# Copy this file to /etc/platespin/platespin.thaw.sh on the Linux source
workload.
###############################################################################

# This scripts works with the /etc/platespin/platespin.freeze.sh script.
# It simply touches the thaw flag file to signal to the freeze script
# that the database tables can be unlocked.

THAW_DONE_FLAG=/tmp/platespin.thaw.done
touch $THAW_DONE_FLAG

exit 0