### Backing up/restoring server data

#### Backing up server data

The server data backup process inspects all of the tables in the database, collecting and then exporting all table data to a ZipEntry. For certain tables, such as the catalog version table, report version table, and report result version table, the data also includes relational real files from the history directory. All server data is compressed to a single Zip file, and all table data and every relational real file is stored as a ZipEntry in this single file.

You have two alternatives for exporting the server data: through the server user interface or through command line.

##### Exporting the server data through the server user interface

1. On the JReport Administration page, click Data on the system toolbar and then select System DB/Realm DB/Profiling DB from the drop-down menu.
2. Select a realm if it is the Realm DB or Profiling DB panel.
3. Click the Backup tab, type the file path and name in the Backup System DB/Realm DB/Profiling DB field (or use the Browse button to specify the file path), and then click Backup. Note that the file extension should be included.

##### Exporting the server data through the command line on Windows or on Unix/Linux

A tool is provided to backup the server data. It is DBMaintain.bat/DBMaintian.sh in <`install_root>\bin`. It has two parameters:

- -Bsystemtables/-Brealmtables/-Bprofiling: Backup the data with the server data in a JReport cluster.
- -B0realmtables: Only backup the data in the database.

To export the server data from the command line on Windows or on Unix/Linux:

1. In a DOS window, switch to the `<install_root>\bin` folder.
2. Use the `DBMaintain` command (DBMaintain.sh on Unix/Linux) and -Bsystemtables/-Brealmtables/-Bprofiling or -B0realmtables parameter. For example:

   `C:\JReport\Server\bin>DBMaintain -Brealmtables:C:\TEMP\cmd_b_realmtables.dat -Bprofiling:C:\TEMP\cmd_b_profiling.dat`

#### Restoring server data

The server data restore process picks up all table data from the backup file and inserts it into the corresponding table in the database. You can only restore server data using the DBMaintain tool with the -Rsystemtables/-Rrealmtables/-Rprofiling or -R0realmtables parameter.

To import server data using the command line:

1. In the DOS window, switch to the `<install_root>\bin` folder.
2. Use the DBMaintain command and -Rsystemtables/-Rrealmtables/-Rprofiling or -R0realmtables parameter, for example:

   `C:\JReport\Server\bin>DBMaintain -Rrealmtables:C:\TEMP\cmd_b_realmtables.dat -Rprofiling:C:\TEMP\cmd_b_profiling.dat`

#### Backup/restoration limitations

The backup/restore feature does not support cross-platform operation. The backup and restore operations must be done on the same operating system. For example, if you backup the server data to a zip file on a Windows platform, you will then not be able to restore it on a Unix system.

Notes:

- On the JReport Administration page, the Profiling DB option is not shown by default on the Data drop-down menu. To make it shown, you need to set the server.profiling.enable property to true in the server.properties file in the `<install_root>\bin` directory.
- When running DBMaintain.bat/DBMaintian.sh, error may occur if the backup zip file is too large, which is caused by JVM limitation. You can try the -B0realmtables and -R0realmtables options to backup and restore data separately.
- When backing up server data in cluster environment, it is recommended that you back up the data on every cluster node to make sure no files get lost on any node after they are restored. Also, the system DB and realm DB should better be backed up together. Since the external data cannot be backed up once just on one single cluster node, to avoid redundant data backup, you need to manually back up the external files on every cluster node after backing up the system DB and realm DB on any of the cluster nodes.
- When restoring server data in cluster environment, first make sure all the cluster nodes are shut down, and then restore the data on each cluster node.