Script API

From wiki.zmanda.com
Revision as of 16:31, 20 February 2008 by Martineau (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Introduction

Pre&Post script are use to execute script before or after amanda command, they can be executed on the client or server, once for each DLE or once for each client.

Script calling convention

This is subject to change

 /path/to/script [execute_on]+ [--config <config>] [--host <host>] [--disk <disk>] [--device <device>]
 input of fd0:
   tool property
 output on fd1
   free format, will go to the amanda debug file.

execute_on can be one or many of:

 pre-dle-selfcheck
 pre-host-selfcheck
 post-dle-selfcheck
 post-host-selfcheck
 pre-dle-estimate
 pre-host-estimate
 post-dle-estimate
 post-host-estimate
 pre-dle-backup
 pre-host-backup
 post-dle-backup
 post-host-backup

Disk and device are provided only if the script is executed for a DLE.

How to use

The script must be defined in amanda.conf

Define the "my_script" script using the "myscript" binary.

 define script-tool my_script {
    comment "a comment"
    "my_script"                       # inherit config of the my_app application
    plugin  "myscript"                # name of the application, it must be installed in dumper dir
    execute_where server              # or client
    execute_on    pre-dle-backup
    property "mailto" "amandabackup"  # can set property
 }

The dumptype must specify the script to use

script-email example

 define script-tool sc-email {
   comment "script-email"
   plugin  "script-email"
   execute_on pre-dle-backup
   execute_where server                  # or client
   property "mailto" "martinea"
 }

your dumptype must include: script "sc-email"

 define dumptype user-tar-email {
   user-tar
   script "sc-email"
 }
 define dumptype user-tar-email2 {
   user-tar
   script {
     "sc-email"
     execute_where client
     execute_on    post-dle-backup, post-host-estimate
   }
 }

Your DLE entry must use the user-tar-email or user-tar-email2 dumptype