Skip to main content

 

Druva Documentation

Pre backup and post backup scripts for File server

Phoenix Editions: File:/tick.png Business File:/cross.png Enterprise File:/tick.png Elite

Overview

Phoenix allows administrators to configure File server agents to execute custom pre-backup scripts and post-backup scripts. Pre-backup scripts are executed before backup jobs to perform specific pre-backup operation. Post-backup scripts are executed after backup jobs to perform specific post-backup operation.  You can configure Backup Policy with the settings for pre-backup and post-backup scripts to perform customer-driven processing tasks. For example,

  • To backup database dumps as flat files using the Phoenix File server agent and delete the dump files after the Phoenix backup job completes.
  • To stop an antivirus service before the backup job and restarting the service after backup completes.

Considerations 

Configuring pre-backup and post-backup scripts in File server backup policy is optional. Before configuring the pre-backup script and post-backup script settings, you should consider the following information:

  • The pre-backup scripts and the post-backup scripts must be present on the same File server, which is configured with Phoenix for backup.
  • You can configure the pre-backup scripts and the post-backup scripts only for Windows and Linux File servers supported by Phoenix.
  • The pre-backup scripts and post-backup scripts should be executable files. Ensure that the scripts are created as per the following conventions:
    • For Linux File server, save the scripts as pre_script.sh and post_script.sh
    • For Windows File server, save the scripts as pre_script.bat and post_script.bat
  •  If the pre-backup script or post-backup script execution fails, alert and email will be generated for the respective script failure at the end of the last retried job. 
  • When the pre-backup or post-backup script is killed externally, for example, through Task Manager or command line (kill -9 <pid>), then the backup cycle gets executed after the context of the script exits.

Steps to configure pre-backup and post-backup scripts

The following diagram depicts the steps to configure pre-backup scripts and post-backup scripts.

Steps to configure custom scripts:

  1. Create pre-backup scripts and post-backup scripts on Windows or Linux File Servers.
    For more information on how to create custom scripts, see Guidelines to create custom backup scripts.
  2. Configure the Backup Policy with the following script settings on the Phoenix portal:
    1. Enable custom script execution for Windows or Linux File server.
    2. Specify the folder location containing scripts on the Windows or Linux File server. 
    3. Specify the option to skip backup operation if the pre-backup script execution fails or pre-backup script is unavailable at the configured location. 
    4. Specify the script timeout option.
      For more information about configuring backup scripts settings, see Pre/Post script settings.
  3. The File server agent executes the pre-backup and post-backup scripts from the path configured in the backup policy on the source server.
    When the pre-backup and post-backup scripts are executed, the agent passes a set of arguments to these scripts.  These arguments are interpreted in the following sequence:
    • For Pre_backup script: [script_name, job_id]
    • For Post_backup script: [script_name, job_id, pre_script_status_integer, backup_status_integer]
      where,
      • script_name represents the absolute path of script.
      • job_id represents the job identification number of the current backup job.
      • pre_script_status_integer represents the status of the pre-script execution. To interpret the values of the pre-script status integers, see Pre-script status.
      • backup_status_integer represents the status of the backup job execution. To interpret the values of the backup status integers, see Backup status.

Workflow of Backup job execution with custom scripts

You must configure the File server backup policy in order to run the custom scripts during backup job execution. Scripts will be executed before and after the backup execution based on the configured Backup Policy.

The following diagram depicts the lifecycle of the backup job when the pre-backup scripts and post-backup scripts are enabled.

|View larger image|

Behavior of pre-backup and post-backup script execution and backup job status

When a File server backup policy is configured with pre-backup and post-backup scripts, the user actions affect the pre-backup and post-backup script execution. The following section describes the behavior of pre-backup and post-backup script execution based on the user interaction.

  • Job Retry: For every Job Retry operation, the pre-backup and post-backup script will execute before and after the backup job. Alert and email will be generated for the respective script failure at the end of last retried job. 
  • Backup job cancel: When a Backup job is canceled during pre-backup script execution,  the pre-backup script is executed,  the backup job is canceled, and the post-backup script is executed. When a backup job is canceled during post-backup script execution, the post-backup script is executed, and the job is canceled.
  • Backup window expiry: When a backup window expires at the time of pre-script execution, the pre-backup script execution exits with the Failed status and the post-backup script is executed.
  • Backup now: When a running job is a manually triggered backup (i.e. Backup Now), the pre-backup and post-backup scripts are executed as expected. 
  • When Phoenix client does not report any status for pre-backup and post-backup scripts, the statuses of the pre-backup and post-backup scripts is N/A

The following table summarizes the statuses of the pre-backup scripts and post-backup scripts corresponding to the statuses of the backup job execution.

Pre script status Run backup? Backup status Run post script? Post script status

Successful

 

Yes

 

Backup status is one of the following:

  • Successful
  • Failed

Yes

 

Post-script backup status is one of the following: 

  • Successful
  • Failed

Successful

 

Yes

 

Backup status is one of the following:

  • Successful
  • Failed

Yes

 

Skipped (when script is unavailable at the specified location)

 

Failed

 

User defined

 

If backup is executed,

  • Successful
  • Failed

If backup is not executed,

  • Failed

Yes

 

Post-script backup status is one of the following:  

  • Successful
  • Failed

Skipped

 

User defined

 

If backup is executed,  the backup status is one of the following:

  • Successful
  • Failed

If backup is not executed, the backup status is,

  • Failed

No

Skipped

 

Guidelines to create custom backup scripts

The following are the best practices to create custom pre-backup and post-backup scripts:

  • Create the pre-backup and post-backup scripts as per the following conventions:
    • Linux File server: pre_script.sh and post_script.sh
    • Windows File server: pre_script.bat and post_script.bat
  • Ensure that the pre-backup and post-backup scripts should not trigger any process in background.