How to run a script before and/or after a backup job

This article is for Amanda Enterprise (AE)

Info Type:General

Info Description:

Sometimes it is desired to perform certain operations just before and/or after a backup job.  Pre- and post-scripts can be used to execute commands before and/or after certain stages of the backup run.  The scripts can be executed on the client or server.

To run a pre-/post-script on the backup server or a Linux/UNIX client, AE uses the Script API.  The script must be located on the backup server or client on which it is run and in the /usr/lib/amanda/application/ directory (or /usr/lib64/amanda/application/ if a 64-bit client system).  The ownership of such script files must be set to amandabackup:disk and should be executable.  To run a script on a Windows client, AE uses a template created on the Windows system (see “Specifying Scripts” in the Zmanda Windows Client documentation).  The scripts can be executed once for each DLE or once for each client host.  Uses for pre- and post-scripts include:

  • to stop and start database servers so that the binary backup is consistent
  • to take a snapshot of a database
  • to send emails or other notifications

In the following example, we will stop a MySQL database on a Linux/UNIX client machine just before the backup and then start the database once the backup completes.

Steps

On the client machine:

Create script files named “script-sql-before” to stop a MySQL database and “script-sql-after” to start the database and put the script files in /usr/lib/amanda/application/ (or /usr/lib64/amanda/application/ if a 64-bit system) on the client machine. The ownership on these script files must be set to amandabackup:disk and should be executable.

On Amanda Server:

Append the following dumptype definitions to /etc/zmanda/zmc/zmc_aee/zmc_user_dumptypes on Amanda Server

define script-tool sql_before {
comment "stop sql database before backup"
plugin "script-sql-before"
execute-on pre-dle-backup
execute-where client
}

define script-tool sql_after {
comment "start sql database after backup"
plugin "script-sql-after"
execute-on post-dle-backup
execute-where client
}

2. Add a DLE on Amanda Server on the Backup| What page to backup the MySQL partition on the client machine.

3. Edit disklist.conf ( located in /etc/amanda/ ) to include the scripts as shown below (Currently ZMC does not have a facily to do this, hence modify this file manually and add the 2 lines)

mysql.server.com "/var/lib/mysql" "/var/lib/mysql" {
        zmc_solaris_base
        compress        none
        estimate        calcsize server
        property        "zmc_type"      "solaris"
        property        "zmc_disklist"  "script"
        property        "zmc_version"   "3"
        property        "zmc_extended_attributes"       "gtar"
        property        "zmc_amanda_app"        "gtar"
        property        "zmc_occ"       "91807232405"
        script  "sql_before"
        script  "sql_after"
        zmc_gtar_app
}

Powered by BetterDocs

Leave a Reply