Using Pre/post Backup Scripts
  • 6 Minutes to read
  • Dark
    Light
  • PDF

Using Pre/post Backup Scripts

  • Dark
    Light
  • PDF

Article Summary

CTERA Agent includes scripts that are executed after logging in to the agent, and before and after a backup. You can use these scripts to perform necessary actions, such as dumping a database to a file before the backup, and after the backup such as deleting temporary files that were created by the pre-backup script.

You can create and manage CTERA Agent scripts within device templates defined in the portal. The scripts are updated and pushed to agents connected to the portal.

Using the CTERA Backup Scripts

You can configure scripts to run at any of the following stages of agent processes:

  • Before backup
  • After backup
  • After logging in

To create a script:

  1. Open the relevant script in a text editor.
    Post login script location: C:\ProgramData\CTERA\CTERA Agent\post-login.cmd
    Pre-backup script location: C:\ProgramData\CTERA\CTERA Agent\pre-backup.cmd
    Post backup script location: C:\ProgramData\CTERA\CTERA Agent\post-backup.cmd
  2. Edit the script.
    You can use the machine environment variables in the script. When creating a script on the portal, the list of available variables is restricted, as described in the CTERA Portal Team Administrator Guide.
  3. Save the script.
    The scripts return an exit code of 0 for success or any other value for failure. Upon failure, the script output is automatically saved to the following locations:
    Post login/etc/ctera/post-login.sh
    Pre-backup/etc/ctera/pre-backup.sh
    Post backup/etc/ctera/post-backup.sh.
    If a script runs longer than 20 minutes, an error is considered to have occurred, and the script is terminated.
Note

The pre-backup and post-backup scripts are executed or terminated as follows:
* If the pre-backup script fails, the backup process does not run, and the post-backup script is executed immediately: The post-backup script is executed whether the pre-backup script succeeded or failed.
* If the user cancels backup, both the pre-backup and post-backup scripts still run to completion.

Example Pre-backup Script

#! /bin/bash
# Prepare for backup here…
/usr/local/mydatabase/dump-database > /backup-files/db-dump
# This script returns success result code
exit 0

Example Post-backup Script

#! /bin/bash
# Clean up
rm –f /backup-files/db-dump
# This script returns success result code
exit 0

Backing Up Oracle With CTERA Scripts

Oracle backup in scripts enables backup capabilities to Oracle database servers by leveraging the CTERA Agent pre/post backup scripts. Oracle scripts are managed by the CTERA portal and made available to run on CTERA Agents. A pre-backup script can be used to invoke the Oracle database native backup utility that is used to generate a database backup file that can then be backed up by the agent. The location for the CTERA backup scripts are platform dependent.

Before You Begin

  • Make sure you have access to the portal version as a team portal administrator.
  • Make sure CTERA Agent is installed on the machine running the Oracle database.

Setting Up the Backup

You set up your backup environment on every Oracle database server.
To set up the backup environment:

  1. Login into the Oracle server.
  2. Create a directory to store the outputs of Oracle recovery manager (RMAN).
  3. Create a script called ctera.rman with the following content:
    • Connection to the database.
    • The backup folder location.
    • Initialization of the Oracle backup event.
  4. Copy the script to a location in your Oracle database server.
  5. Locate the absolute path to the Oracle recovery manager executable.
    :::(Info) (Note)The RMAN location is platform dependent. For example, RMAN in Windows might be located in C:\Oracle\Ora12c\bin\RMAN.exe. RMAN in Linux might be located in /u01/app/oracle/product/11.2.0/db_1/bin.
  6. Modify the CTERA pre-backup.cmd script for the platform where the Oracle database server is located to perform the following:
    • Start RMAN shell from its location.
    • Run the RMAN script created in the RMAN Shell.
  7. Repeat the procedure on every Oracle database server you want to back up.

Back Up an Oracle Server

When backing up a single Oracle Server, perform the following procedure.

Note

To back up multiple Oracle servers or automate the process of backing up a single server you have to create a configuration template.

To backup an Oracle server:

  1. Run Oracle Backup by using the RMAN shell or Enterprise Manager Database Console.
    The output from this step is used as the input in the CTERA agent in the next step.
  2. Click Backup now in your CTERA Agent console.

The Oracle Database files are backed up to the cloud.

Back Up Multiple Oracle Servers

Backing up multiple Oracle database servers to the cloud simultaneously is possible using the Oracle Scripts feature and a CTERA Portal configuration template.
The CTERA portal provide a convenient platform to schedule, manage and execute backup operations on multiple multi-platform Oracle Database servers.

Note

You can also use this procedure to manage and execute backup operations on a single Oracle database server.

Configuring the Portal

Set up a configuration template that will enable you to manage and execute backup operations on multiple Oracle database servers.

To set up the backup environment for multiple Oracle servers:

  1. Login into the CTERA team portal as an administrator and select Settings > Configuration Templates in the navigation pane.
    The CONFIGURATION TEMPLATES page is displayed.
  2. Either:
    • Add a new template, click New Template.
      The New Configuration Template window is displayed.
      Or,
    • Edit an existing configuration template, click the template’s name.
      The configuration template window is displayed with the configuration template name as the window title.
  3. Enter the general details for the template:
    Name – A unique name for the template. Spaces and special characters cannot be used in the name.
    Description – A description of the template.
  4. in the configuration template window, select the Backup Sets option.
  5. Click New to add a new backup set or select a backup set and click Edit to change it.
  6. Set the details and if required, conditions for the backup set:
    Backup Set Name – A name for the backup set.
    Comment field – A description of the backup set.
  7. If required, specify conditions for the backup set, as described in the CTERA Portal Team Administrator Guide.
  8. Click NEXT.
  9. Click Add a file or folder to add the path of the directory that stores the RMAN outputs.
    A row is added to the table.
    Note

    The path to the directory that stores the RMAN output is platform dependent. You can add multiple directory path locations by clicking Add a file or folder again.

  10. Click NEXT and FINISH.
    The new backup set is created.
  11. in the configuration template window, select the Backup Schedule option.
  12. Click Manage, if the backup schedule is unmanaged. The device template will manage which backup schedule for devices using this template. Management of backup schedules is disabled in the devices' local administration interfaces.
    The backup can be one time event that will place for all servers in the specified date and time or recurring backup operation.
  13. Configure the backup schedule.
  14. In the configuration template window, select the Scripts option
  15. Click Manage, if the scripts are unmanaged. The device template will manage scripts for devices using this template.
  16. Open the relevant server platform tab and enter the appropriate command in the script window.
    For example, if the Oracle Database server is a Windows server, use a command similar to the following: C:\Oracle\Ora12c\bin\RMAN.exe @ C:\Oracle\ctera\ctera.rman.
    Note

    The RMAN location is platform dependent. For example, RMAN in Linux is located in /u01/app/oracle/product/11.2.0/db_1/bin.

  17. Click SAVE.
  18. Select the newly created template and click Set Default.
    The Oracle database will be backed up at the scheduled time.
  19. Click Auto Assign in the CONFIGURATION TEMPLATES page.

By default, if there are no conditions specified, the Oracle backup template, set as the default template, is used for all devices.


Was this article helpful?