Liquibase Enterprise was formerly known as Datical DB.

Custom Backup and Restore Methods

During packaging, the REF database is backed up and restored. Deployment Packager uses common backup and restore operations supported by each database.  

To use another method, you can write a custom backup and restore class in a Groovy script and configure Deployment Packager use it. 

Overview

To implement a custom backup and restore class, do the following:

  1. Write the class - Use the provided sample scripts as a starting point and write a custom script. In the script, write a class with methods for backup and restore. Place it in the default location or a custom location. 

    Note

    The Groovy script name and the class name should use the same name. Use the naming convention BackupRestore<dbname><name>. 

    Example:  BackupRestoreOracleCustom.groovy should contain class BackupRestoreOracleCustom

  2. Test the class - Use the provided test script to test the custom script outside of Deployment Packager. 
  3. Configure Deployment Packager - Use new properties in deployPackager.properties to have Deployment Packager use the custom script. 
    • databaseBackupRestoreMethod 
    • extensionsPath
  4. Test the class again. Run Deployment Packager manually with test scripts. 

Writing a Custom Script

To provide a custom backup and restore method to use, do the following:

  1. Implement a custom class inside a groovy script. Two example scripts are provided:
    • BackupRestoreOracleCustom.groovy - This script is a copy of the default backup and restore script that Deployment Packager uses for Oracle. It uses Oracle's expdp and impdp command-line tools. 
    • BackupRestoreCustomStub.groovy - A mostly-empty stub script with comments. It runs successfully in the test script but performs no actions. 
  2. Place the groovy script where you want it.
    • The default location for custom scripts is <datical-install>/repl/scripts/extensions.  
    • If you place the custom script in another location, you can set the property extensionsPath in deployPackager.properties 

Testing a Custom Script

Use the provided test script to test your custom script without running Deployment Packager.

<datical-install>/repl/scripts/database_backup_restore.groovy

To get help on the script, run it without any arguments. 

Specify a DbDef (for the database to work on) plus any other arguments that you have implemented. 

hammer groovy database_backup_restore.groovy <dbdef> [backup | restore]

Backup Test

The backup test follows these steps:

  1. Checks the settings databasebackupRestoreMethod and databaseBackupRestoreLocation.  
  2. Checks the DbDef
  3. Runs a backup and reports status (success, failure)
  4. Reports final status (success, failure)

Restore Test

The restore test requires a prior backup. It follows these steps:

  1. Checks the settings databasebackupRestoreMethod and databaseBackupRestoreLocation.  
  2. Checks the DbDef
  3. Runs a restore and reports status (success, failure)
  4. Reports final status (success, failure)

Customizing the Test Script

Copy and edit the provided test script. Add other tests to the script as you need. 

Configuring Deployment Packager

See Use the Required deployPackager.properties File

Add properties to <project>/deployPackager.properties:

  •  databaseBackupRestoreMethod - Required. The name of the custom class. It should match the Groovy script name (without the .groovy extension). 

    databaseBackupRestoreMethod=BackupRestoreOracleMyCustom
  • extensionsPath - Optional. If you place the custom Groovy script in a location other than the default  <datical-install>/repl/scripts/extensions, then set this property. 

    extensionsPath=C:\\Datical\\DaticalDB\\DaticalCustomExtensions

Example Scripts

Example scripts are provided in <datical-install>/repl/scripts/extensions

  • BackupRestoreCustomStub.groovy is a stub that can be used as a starting point for a custom backup restore implementation.
  • BackupRestoreOracleCustom.groovy is an example of a working implementation.


Copyright © Liquibase 2012-2022 - Proprietary and Confidential