Schedule JasperServer Repository Export

Schedule JasperServer Repository Export

Export of JasperServer Repository :

  1. Access the server where jasperserver is installed. It can be on your local machine as well as on remote server. If the jasperserver is installed in local machine then run command in command prompt. Else connect to the remote server through putty and run commands.
  2. Jasperserver provide us with the import-export utility by using which export of any kind of data on server can be taken.
  3. The import and export utilities are shell scripts located in the:

<js-install>/buildomatic  folder.

  • Windows: <js-install>\buildomatic\js-import.bat
    <js-install>\buildomatic\js-export.bat
  • Linux: <js-install>/buildomatic/js-import.sh

                <js-install>/buildomatic/js-export.sh

More information about jasper utility and the command can be found at “http://community.jaspersoft.com/documentation/jasperreports-server-administration-guide/v550/import-and-export-through-command-line”

  1. JasperReports server should be stopped when using the import and export utilities. This is very important for the import utility to avoid issues with caches, configuration, and security.
  1. Go the path <js-install>/buildomatic and Run the command :

Unix:

js-export.sh  –uris /public/ Reports –output-zip E:\document \report.zip

Windows:

js-export.bat  –everything –output-zip E:\document \report.zip

  1. After complete execution of above command you’ll be able to get the required export in the given directory with the given output file name.
  2. Next task is to create the script which we can run on server. Here is an example of shell script which can be run on unix server.
  3. In this script following variables are declared:

# Path to buildomatic directory of Jasperserver that contains the js-export script: JASPER_BUILDPATH=/opt/jasperreports-server-6.3.0-bin/buildomatic/

# URI of Jasper repository folder to be dumped:

REPO_REPPATH=/public/Reports

# Destination directory for backup files:

DUMP_DIR=/home/server/JasperBackup/

# Destination output file name for backup file:

OUTPUT=repo_bkp

# export of the jasper repository

DATETIME=date +%Y%m%d%H%M%S

Next ,

cd ${JASPER_BUILDPATH} has been used to go to the js-install path.

Where the export command can be run.

./js-export.sh –uris ${REPO_REPPATH} –repository-permissions –output-zip ${DUMP_DIR}${OUTPUT}_${DATETIME}.zip

In this,

if [ $? -eq 0 ]; then

echo “Backup is taken Successfully. Backup File – ${DUMP_DIR}${OUTPUT}_${DATETIME}.zip”

else

echo “Backup Failed. Please check the above log for any errors.”

Fi

We are writing in the log file on the successful/unsuccessful completion of the backup.

a

We can run this script on server with command “sh script_name.sh”.

Schedule Export of JasperServer Repository :

  1. Crontab syntax :
    A crontab file has five fields for specifying day , date and time followed by the command to be run at that interval. bn
  2. Type in ‘Crontab -e’ in server, following screen will appear:

3

Nano editor will open

Type in there:

/5  * * * /home/server/JasperBackup/jasper_backup.sh >> /home/jasper/JasperBackup/log.txt 2>&1

Here we are scheduling the execution of “jasper_backup.sh” file in every 5 minutes. You can schedule as per the requirement.

Thank You

Nisha Sahu