Skip to content

Backup and restore

One of the most important things to have is an up-to-date backup of your OpenKM.

If you have followed the installation instructions, you have configured OpenKM to use a production-safe database and optionally set a path to the OpenKM repository data store.

In that case:

  1. First, back up your database (make a SQL dump).
  2. Then, back up your data on the filesystem.

Backup steps:

An alternative to traditional backup methods is to export the whole repository from OpenKM Administration > Utilities > Repository export and choose metadata and history options. However, we do not recommend this method of backing up; we suggest incremental backup solutions for medium to large repositories.

You can follow these steps to back up and restore if you have OpenKM configured with MySQL or MariaDB. For other databases, check the corresponding commands.

Terminal window
$ systemctl stop openkm
$ mysqldump -h localhost -u root -p okmdb > /path/to/openkm/okmdb.sql
$ zip -r /path/to/backup/okm-backup.zip /path/to/openkm
$ systemctl start openkm

After that, you will have a ZIP archive with the whole OpenKM installation and the exported database. Please check before deleting this installation. We always recommend restoring the backup to ensure you have all the required files.

Please note that you must create the database if it wasn’t created previously. On Ubuntu, if using MySQL or MariaDB, use this command to install it:

Terminal window
$ sudo apt install mariadb-server

In the case of CentOS:

Terminal window
$ sudo yum install mariadb-server

And execute the following statements:

CREATE USER 'openkm'@'localhost' IDENTIFIED BY 's3cr3t0';
CREATE DATABASE okmdb DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_bin;
GRANT ALL ON okmdb.* TO 'openkm'@'localhost' WITH GRANT OPTION;

Remember that the user and database names may be different in your case. Please take a look at the installation report or check it at $TOMCAT_HOME/openkm.properties.

Once created, restore the database and files:

Terminal window
$ unzip /path/to/backup/okm-backup.zip -d /path/to/restore
$ mysql -h localhost -u root -p okmdb < /path/to/restore/okmdb.sql

Set the permissions according to the user who starts OpenKM:

Terminal window
$ sudo chown openkm:openkm /path/to/openkm -R

Install the required dependencies. In the case of Ubuntu:

Terminal window
$ sudo apt install xvfb imagemagick libreoffice tesseract-ocr

In the case of CentOS:

Terminal window
$ sudo yum install ImageMagick tesseract libreoffice libreoffice-headless

Once restored, verify file permissions, start OpenKM, and perform a repository check. See Repository checker.

You can follow these steps to back up and restore if you have OpenKM configured with MySQL or MariaDB. For other databases, check the corresponding commands.

After that, you will have a ZIP archive with the whole OpenKM installation and the exported database. Please check before deleting this installation. We always recommend restoring the backup to ensure you have all the required files.

Please note that you must create the database if it wasn’t created previously. In the case of MySQL or MariaDB, please download from:

Once installed, execute the following statements to create the database user and OpenKM database:

CREATE USER 'openkm'@'localhost' IDENTIFIED BY 's3cr3t0';
CREATE DATABASE okmdb DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_bin;
GRANT ALL ON okmdb.* TO 'openkm'@'localhost' WITH GRANT OPTION;

Remember that the user and database names may be different in your case. Please take a look at the installation report or check it at $TOMCAT_HOME/openkm.properties.

Once created, restore the database and files:

Terminal window
C:\> unzip okm-backup.zip -d C:\
C:\> mysql -h localhost -u root -p okmdb < okmdb.sql

Set the permissions according to the user who starts OpenKM.

Once restored, verify file permissions, start OpenKM, and perform a repository check. See Repository checker.