Using Pre and Post Scripts

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

Copyright © SEP AG 1999-2019. 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/4.4.3 Grolar. 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 an antivirus service before the backup. Similarly, pre restore scripts are executed before 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. Similarly, post restore scripts are executed after the restore is done, for example, to start a database.

Pre and post scripts are represented as one of SEP sesam interfaces. These are configurable programs which can be programmed by using 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, the pre/post interfaces relate to a specific client only; they are created for each client individually and are only executed on the selected client.

Information sign.png Note
Configuring pre and/or post scripts is optional. The pre/post interface might affect backup or restore execution; when creating a script, have in mind that any pre/post script should not take a long time to complete 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 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.
    Configuration interfaces pre.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.jpg
  3. A new window with the Edit <name> interface script opens, allowing you to configure (insert) 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 standard output.
    • If you want to change a backup source, STATUS: messages have to includes keyword BACKUP_SRC=, for example, STATUS:OK BACKUP_SRC=C:,F:/DATA. It this case the backup will use this source instead of the source defined in a backup task.

    Pre interface.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 in the Post log file during the backup.
    • If the post process ends with an error, the backup will complete with status Warning.
  5. After configuring a relevant pre or post action, click Save to activate the interface on a specific client.

Upon saving the template the script is read and copied to the <SESAM_ROOT>/bin/sesam. Now you have to add a pre/post script to backup or restore tasks.

For more examples on how to use pre and post scripts, see Configuring ownCloud restore.

Activating interfaces manually

Alternatively, you can activate the interfaces by copying the existing templates from the SEP sesam directory <SESAM_ROOT>/skel/templates under the names:

sbc_pre
sbc_post

to the directory <SESAM_ROOT>/bin/sesam.

Selecting a pre/post script for backup or restore

After configuring desired pre/post actions, specify whether any pre or post script should be applied on a specific client, by adding the script to backup or restore task.

Selecting a pre/post script for backup

You can select to run a pre/post script when creating 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.png
  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 backup even if the pre-script was not properly executed.
    • Ignore backup error: Enable it to allow to execute the post script after a faulty backup.
  3. Click OK to activate the pre/post script execution 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 in the final Save and Start step of the restore wizard.

  1. In the Save and start step of the restore wizard, click Expert options and then select the tab Pre/Post.
    Restore pre post.jpg
  2. Depending on the desired action, 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 restore even if the pre-script was not properly executed.
    • Start post in spite of restore error: Enable it to allow to execute the post script after a faulty restore.
  3. Click OK to activate the pre/post script execution for the selected task.