Using Pre and Post Scripts

From SEPsesam
Jump to: navigation, search
Other languages:
Deutsch • ‎English

Copyright © SEP AG 1999-2022. All rights reserved.

Any form of reproduction of the contents or parts of this manual is allowed only with the express written permission from SEP AG. When compiling and designing user documentation SEP AG uses great diligence and attempts to deliver accurate and correct information. However, SEP AG cannot issue a guarantee for the contents of this manual.

Docs latest icon.png Welcome to the latest SEP sesam documentation version 4.4.3 Beefalo/5.0.0 Jaglion. For previous documentation version(s), check Documentation archive.


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.

Information sign.png 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.

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

  1. From Configuration -> Interfaces, select the relevant interface type (Pre or Post) that you want to activate.
    Activating interfaces Beefalo V2.jpg
  2. 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.
    Edit pre interface Beefalo V2.jpg
  3. A new window with the Edit <name> interface script opens, allowing you to configure (insert) a specific action at the end of the script.
    Information sign.png 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.

    Pre interface Beefalo V2.jpg

    • 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:
      • echo "shutdown -h +2"
        shutdown -h +2
        
  4. 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.
  5. After configuring a relevant pre or post action, click Save to activate the interface on a specific client.

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.

  1. 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.
    Tasks options Beefalo V2.jpg
  2. 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.
  3. 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.

Information sign.png 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.
  1. In the Target Settings dialog, click Expert Options, and then select the Pre/Post tab.
    Restore pre post Beefalo.jpg
  2. 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.
  3. Click OK to enable execution of the pre/post script for the selected task.