Backing Up all Jedox Data with Batch Files

image_pdfimage_print

On Windows, a backup of all changed data in Jedox can be easily run with a scheduled task and a batch file. On Linux, we recommend a similar execution of cron jobs.

The following script of a batch file will back up all changed data in a standard Jedox installation. If you have an older Jedox version or a customized installation, then you have to adapt the script to your installation. 

@echo off
 set Backup_folder=d:\Jedox\Backup
 set Current_backup_folder=%Backup_folder%\backupset0
 set Jedox_suite_folder=C:\Program Files (x86)\Jedox\Jedox Suite
 set Jedox_data_folder=%Jedox_suite_folder%\olap\data
 set Jedox_storage_folder=%Jedox_suite_folder%\storage
 set Jedox_etlserver_data_folder=%Jedox_suite_folder%\tomcat\webapps\etlserver\data
  
 if /I "%1" EQU "StopService" goto StopService
 if /I "%1" EQU "StartService" goto StartService
 if /I "%1" EQU "MaintainBackups" goto MaintainBackups
 if /I "%1" EQU "DoBackup" goto DoBackup
  
 :Main
 call %0 StopService JedoxSuiteHttpdService
 call %0 StopService JedoxSuiteCoreService
 call %0 StopService JedoxSuiteTomcatService
 call %0 StopService JedoxSuiteMolapService
 call %0 MaintainBackups
 call %0 DoBackup 
 call %0 StartService JedoxSuiteMolapService
 call %0 StartService JedoxSuiteCoreService
 call %0 StartService JedoxSuiteTomcatService
 call %0 StartService JedoxSuiteHttpdService
 goto :EOF
  
  
 :StopService
 @echo Stopping %2
 set /a Max_wait_time=600
 net stop %2
 :Waiting_stopped
 for /F "tokens=3 delims=: " %%H in ('sc query "%2" ^| findstr " STATE"') do (
   if %Max_wait_time% LEQ 0 GOTO :StopTimeout
  
   if /I "%%H" NEQ "STOPPED" (
     ping localhost -n 6 > nul
     set /a Max_wait_time = Max_wait_time - 5
     goto Waiting_stopped
   )
 )
 goto :EOF
  
 :StopTimeout
 @echo Timeout waiting for service %2 to stop
 exit
  
 :StartService
 @echo Starting %2
 set /a Max_wait_time=600
 net start %2
 :Waiting_started
 for /F "tokens=3 delims=: " %%H in ('sc query "%2" ^| findstr " STATE"') do (
   if %Max_wait_time% LEQ 0 GOTO :StartTimeout
  
   if /I "%%H" NEQ "RUNNING" (
     ping localhost -n 6 > nul
     set /a Max_wait_time = Max_wait_time - 5
     goto Waiting_started
   )
 )
 goto :EOF
  
 :StartTimeout
 @echo Timeout waiting for service %2 to start
 exit
  
 :MaintainBackups
 rmdir /S /Q %Backup_folder%\backupset7
 ren %Backup_folder%\backupset6 backupset7
 ren %Backup_folder%\backupset5 backupset6
 ren %Backup_folder%\backupset4 backupset5
 ren %Backup_folder%\backupset3 backupset4
 ren %Backup_folder%\backupset2 backupset3
 ren %Backup_folder%\backupset1 backupset2
 ren %Backup_folder%\backupset0 backupset1
 mkdir %Backup_folder%\backupset0
 goto :EOF
  
 :DoBackup
 del "%Current_backup_folder%\*.*" /Q
 mkdir %Backup_folder%\backupset0\olap_data
 mkdir %Backup_folder%\backupset0\storage
 mkdir %Backup_folder%\backupset0\httpd_conf
 mkdir %Backup_folder%\backupset0\httpd_app_etc
 mkdir %Backup_folder%\backupset0\httpd_php
 mkdir %Backup_folder%\backupset0\core
 mkdir %Backup_folder%\backupset0\tomcat_conf
 mkdir %Backup_folder%\backupset0\etlserver_data
 mkdir %Backup_folder%\backupset0\docroot_pr_custom
 mkdir %Backup_folder%\backupset0\svs
 xcopy "%Jedox_data_folder%\*.*" "%Current_backup_folder%"\olap_data /Y /E
 rem activate next line to remove *.bin files from the backup. This saves space at cost of a slower first start after a restore.
 rem del /s "%Current_backup_folder%"\olap_data\*.bin"
 xcopy "%Jedox_storage_folder%\*.*" "%Current_backup_folder%"\storage /Y /E
 xcopy "%Jedox_suite_folder%\httpd\conf\*.*" "%Current_backup_folder%"\httpd_conf /Y /E
 xcopy "%Jedox_suite_folder%\core\palo_config.xml" "%Current_backup_folder%"\core /Y
 xcopy "%Jedox_suite_folder%\core\ui_backend_config.xml" "%Current_backup_folder%"\core /Y
 xcopy "%Jedox_suite_folder%\httpd\app\etc\config.php" "%Current_backup_folder%"\httpd_app_etc /Y
 xcopy "%Jedox_suite_folder%\httpd\php\php.ini" "%Current_backup_folder%"\httpd_php /Y
 xcopy "%Jedox_etlserver_data_folder%\*.*" "%Current_backup_folder%"\etlserver_data /Y /E
 xcopy "%Jedox_suite_folder%\tomcat\conf\server.xml" "%Current_backup_folder%"\tomcat_conf /Y
 xcopy "%Jedox_suite_folder%\httpd\app\docroot\pr\custom\*.*" "%Current_backup_folder%"\docroot_pr_custom /Y /E
 xcopy "%Jedox_suite_folder%\svs\sep.inc.php" "%Current_backup_folder%"\svs /Y
 xcopy "%Jedox_suite_folder%\svs\custom_scripts\*.*" "%Current_backup_folder%"\svs /Y /E
 xcopy "%Jedox_suite_folder%\svs\sample_scripts\*.*" "%Current_backup_folder%"\svs /Y /E
 rem remove *.archive files
 del /s "%Jedox_data_folder%\*.archive"
image_pdfimage_print
Was this post helpful?
NoYes (+1 rating, 3 votes)
Loading...