In this article, we will show you how to copy databases via ETL. This method does not require a service restart. All you need is a groovy script that is run in Groovy job. For this example, we will use the “Demo” database.

Groovy script

copyJedoxDatabase( ‘Demo’, ‘Demo_Copy’ )
void copyJedoxDatabase( String jedoxConnectionSrc, String jedoxDatabaseDst ) {
String jedoxDatabaseSrc = OLAP.getDatabase( jedoxConnectionSrc ).getName()
String backupFilename = API.getProperty( “Demo_Copy” ) + jedoxDatabaseSrc + ‘.zip’
// Remove backupFile if exists (e.g. from a previous run)
new File( backupFilename ).delete()
IDatabase db = OLAP.getDatabase( jedoxConnectionSrc )
LOG.info( ‘Saving database ‘ + jedoxDatabaseSrc + ‘ to ‘ + backupFilename )
db.backup( backupFilename )
IConnection conn = OLAP.getConnection( jedoxConnectionSrc )
LOG.info( ‘Restoring database ‘ + jedoxDatabaseDst + ‘ from ‘ + backupFilename )
conn.addDatabase( jedoxDatabaseDst, backupFilename )
boolean fileSuccessfullyDeleted = new File( backupFilename ).delete()
}
Copy database

Once the job is run, the new database will appear in the modeler.

ETL job can be downloaded from this location.

4 Comments

  • Hi Madhu, the new database will be located in the /Data folder on the backend side. The example of this Integrator project is hyperlinked in the “ETL job can be downloaded from this location.” in the text. I hope this answers your questions.

  • Rick Clazie

    Hi – we’ve been playing with this API for the past couple weeks and running into the same issue we are getting with your script. It works great the first time, but then subsequent runs report:
    ‘2024-03-12 21:40:44 ERROR Unable to execute groovy job: internal error,”target file already exists”, (Olap server error code: 2) (job job_groovy_DB)’

    Any suggestions on how to properly delete this file to let the process re-run?

Leave a Reply

Your email address will not be published. Required fields are marked *

Leave the field below empty!