5 1 0:Using Pre and Post Scripts
Overview
SEP sesam enables system administrators to perform additional actions before and/or after a backup or restore by using pre or post scripts.
Pre backup scripts are executed before backup jobs starts to perform specific operation. Typically, they are used to create commands that will stop or start the selected programs, for example, to stop a database or antivirus service before the backup. Similarly, pre restore scripts are executed before the restore starts.
Post backup scripts are executed when the backup session stops to perform specific tasks, such as starting a database or shutting down a computer after the backup. Post restore scripts are executed after the restore, for example, to start a database.
Pre and post scripts are represented as one of the SEP sesam interfaces. They are configurable programs hat can be programmed with any text editor. Pre and post scripts are not provided by SEP sesam; you must create your own scripts to perform the desired actions.
Unlike other SEP sesam interfaces, pre/post interfaces apply only to a specific client; they are created for each client individually and run only on the selected client.
Note | |
Configuring pre and/or post scripts is optional. The pre/post interface may affect the execution of backups or restores. When creating a script, keep in mind that a pre/post script should not take a lot of time, as it can delay a backup or restore. |
To use the pre/post script, you have to activate the relevant interface first and then create your own script.
Note | |
If you want to run pre or post actions for migration tasks, configure the appropriate scripts in files sm_copy_pre and sm_copy_post (on Windows add the .bat extension, for example, sm_copy_pre.bat), and place these files in <SESAM_ROOT>/bin/sesam directory. When a migration task is started (and finished), the directory is checked. If these files exist, they will be executed before and/or after migration.
|
Configuring pre and post scripts
SEP sesam provides several interface templates. They are located in the SEP sesam directory <SESAM_ROOT>/skel/templates
. You can activate them automatically via the GUI (recommended) or manually by copying them.
Activating interfaces via SEP sesam GUI
- From Configuration -> Interfaces, select the relevant interface type (Pre or Post) that you want to activate.
- The Edit Pre/Post Interface window opens: Select Backup or Restore interface and the client on which you want to run the script. Click OK.
- A new window with the Edit <name> interface script opens, allowing you to configure (insert) a specific action at the end of the script.
Note - Before the end of the procedure either STATUS:OK or STATUS:ERROR {text} must be written to the standard output.
- If you want to change a backup source, STATUS: messages have to include keyword BACKUP_SRC=, for example, STATUS:OK BACKUP_SRC=C:,F:/DATA. In this case, the backup will use this source instead of the source defined in a backup task.
- For example, you may want to shut down a specific computer after the backup is finished. To configure this action, you have to select Post backup interface for a relevant client and add the following lines at the end of the sbc_post script:
- For Windows
#=== Please insert your specific actions here ===================================== echo "shutdown -s -t 120" shutdown -s -t 120 rem echo STATUS:ERROR {message} echo STATUS:OK exit
- For Linux:
- This action invokes a shutdown of the computer two minutes after the backup has finished.
- The first line shutdown ... is the message which is written to the Post log file during the backup.
- If the post process ends with an error, the backup is completed with the Warning status.
- After configuring a relevant pre or post action, click Save to activate the interface on a specific client.
echo "shutdown -h +2" shutdown -h +2
When you save the template, the script is read and copied to the <SESAM_ROOT>/bin/sesam
folder. Now you have to add a pre/post script to backup or restore tasks.
For more examples of how to use pre and post scripts, see Configuring ownCloud restore.
Manual activation of interfaces
Alternatively, you can activate the interfaces by copying the existing templates from the SEP sesam directory <SESAM_ROOT>/skel/templates
under the name:
sbc_pre sbc_post
into the <SESAM_ROOT>/bin/sesam
directory.
Selecting a pre/post script for backup or restore
After configuring the desired pre/post actions, specify whether to apply a pre/post script to a specific client by adding the script to the backup or restore task.
Selecting a pre/post script for backup
You can select to run a pre/post script when you create a backup task or apply it to an already configured task. For details on how to create a new backup task, see Creating a Backup Task.
- From Main Selection-> Tasks-> By Clients, select your client and double-click it or click New Backup Task. The Properties or New Backup Task window opens. Switch to the Options tab.
- Depending on the desired action, select either Execute pre or Execute post backup and/or restore option(s):
- Execute pre: Enable it if you want to run the pre script for this backup task.
- Execute post: Enable it if you want to run the post script for this backup task.
- Ignore pre error: Enable it to allow to force start the backup even if the pre script was not properly executed.
- Ignore backup error: Enable it to allow the post script to run after a failed backup.
- Click OK to enable execution of the pre/post script for the selected task.
Selecting a pre/post script for restore
You can select to run a pre/post script when creating a restore task or apply it to an already configured task (Main Selection -> Job State -> Restores -> open Properties). For details on how to create a new restore task, see Standard Restore Procedure. In both cases, you can select to run a pre/post script under the Expert Options.
Note | |
The Expert Options button for specifying advanced restore options is available only in advanced UI mode (formerly expert GUI mode). To use Expert Options, make sure your UI mode is set to advanced. For details, see Selecting UI mode. |
- In the Target Settings dialog, click Expert Options, and then select the Pre/Post tab.
- Depending on the action you want to take, select either Execute pre or Execute post restore option(s):
- Execute pre: Enable it if you want to run the pre script for this restore task.
- Execute post: Enable it if you want to run the post script for this restore task.
- Start restore in spite of pre error: Enable it to allow to force start the restore even if the pre script was not properly executed.
- Start post in spite of restore error: Enable it to allow the post script to run after a failed restore.
- Click OK to enable execution of the pre/post script for the selected task.
See also
Interfaces – Pre/post options – Configuring ownCloud Restore