Backup and restore

One of the most important things to have is an updated backup of your OpenKM.

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

OpenKM has several configurations, but for optimal performance we recommend:

  • Use the default data store that saves binary information directly to the server disk (in a non human comprehensible format).
  • All the other information, folders and documents structure, metadata, etc., is stored in the database.

OpenKM allows the use of other datastores, for example to save binary data into a database.

In this case:

  1. First backup your database (make a SQL dump)
  2. Then backup your data on filesystem

By default, all documents are stored in $TOMCAT_HOME/repository. This default folder can be changed using the property repository.home in the file $TOMCAT_HOME/OpenKM.cfg file.

Although OpenKM supports hot backups of your data, it is recommended to stop Tomcat before starting the backup. Apply this good practice when possible.

Backup steps:

  • Stop Tomcat (optional).
  • Backup the database (mandatory).
  • Backup the repository folder (mandatory).
  • Start Tomcat (optional).

Performing the backup in that order (the database first, then the filesystem) will ensure backup consistency.

There is an alternative to traditional backup methods: you can export the whole repository from OpenKM Administration > Utilities > Repository export and choose metadata and history options. But we do not suggest this way of doing backups. For medium to large repositories we suggest some incremental backup solution.

Detailed steps

In case you have OpenKM configured with MySQL or MariaDB you can follow these steps to backup and restore. For other databases check its corresponding command.


$ /etc/init.d/tomcat stop
$ mysqldump -h localhost -u root -p okmdb > /path/to/openkm/okmdb.sql
$ zip -r /path/to/backup/ /path/to/openkm
$ /etc/init.d/tomcat start

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


Please, note that you have to create the database if wasn't created previously. In case of MySQL or MariaDB install it:

$ sudo apt install mariadb-server

And execute the following sentences:

CREATE USER 'openkm'@'localhost' IDENTIFIED BY 's3cr3t0';
GRANT ALL ON okmdb.* TO 'openkm'@'localhost' WITH GRANT OPTION;

Keep on mind that the user and database name may be different in you case. Please, take a look at the installation report or check it at $TOMCAT_HOME/conf/server.xml 

Once created restore the database and files:

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

Set the permissions according to the user who start OpenKM:

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

Install the required dependencies:

$ sudo apt install gawk imagemagick libreoffice tesseract-ocr

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

Backup scripts

Additional information