Using Integrator for Database Backup

You can use IDatabase.backup method inside a Jedox Integrator Groovy job to execute a backup of databases. Such a job can then be triggered or scheduled to be run on a regular basis to produce database backups, without the need to shutdown any of the services. Backup itself runs asynchronously in non-blocking mode, hence regular work should not be impacted provided enough system resources are available. For every database, a separate ZIP archive will be produced containing the database itself plus the System database. Both of these are in a committed state - all journals are processed and no archives are present in a zip file which, when used, speeds up startup times of the database server. Use the zip-backup parameter to influence the compression level used.

Assuming there is a connection of type Jedox called localhost_demo which points to database Demo, a bare minimum Groovy script which backups Demo database to a file Demo.zip inside Data directory could look like this:

IDatabase db = OLAP.getDatabase("localhost_demo");
db.backup("Demo.zip");

A more comprehensive script which backups all the databases for a specific connection and adds timestamp suffix to archive name is included in the Integrator Sample project "ETLTasks" in the setup, and looks similar to the code below:

Copy
// path to backup directory - data directory will be used if empty
 String backupDirPath = "${BackupDirPath}";
 // definition of helper function for backing up single DB
 def backupDb(db, backupDirPath){
       // get current date/time
     Date dateNow = new Date();
     String newDate = dateNow.format( 'yyyyMMdd_HHmm' );
     // get suffix for backup file
     String suffix = "_" + newDate + ".zip";
       String dbN = db.getName();
       String fileName = backupDirPath + dbN + suffix;  
       if (dbN != "System")
       {
         LOG.info("Starting backup of database: '" + dbN + "'.");
         LOG.info("Trying to write filename: '" + fileName + "'.");
         try
         {
               db.backup(fileName);
               LOG.info("Finished backup of database: '" + dbN + "'.");
         }
         catch (pExc)
         {
               LOG.error(pExc);
         }
      }
 }  
 IConnection conn = OLAP.getConnection("OlapTarget");
 if (conn != null)
 {
   LOG.info("_______________________________________________________________________________");
   for(IDatabase db:conn.getDatabases())
   {
     backupDb (db, backupDirPath);
   };
   LOG.info("_______________________________________________________________________________");
 }
 else
 {
   LOG.error("No connection defined.");
 }

It relies on at least the JedoxGlobal connection OlapTarget being properly set. By default, if the backupDirPath variable is not set, the backup job will write a ZIP file in the data directory of the Jedox In-Memory DB; otherwise, the directory specified as a value for the backupDirPath variable is used. For this variable, forward slashes must be used as separators between directory names; backslashes are not allowed. The format of the archive name is <DB_NAME>_<DATE_TIME>.zip, e.g. Demo_20160321_1536.zip. Please note that the user running the Jedox In-Memory DB Server service/process must have write access to the target directory to be able to create the output file.

Updated June 5, 2023