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:
- First, back up your database (make a SQL dump).
- Then, back up your data on the filesystem.
Backup steps:
- Stop Tomcat
- Back up the database
- In case of MariaDB, please visit Full Backup and Restore with Mariabackup
- In case of PostgreSQL, please visit PostgreSQL Backup and Restore
- In case of SQL Server, please visit Create a Full Database Backup
- In case of MySQL, please visit MySQL Backup and Recovery
- Back up the Tomcat or repository folder
- Start Tomcat
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.
Linux detailed steps
Section titled “Linux detailed steps”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.
Backup
Section titled “Backup”$ 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 openkmAfter 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.
Restore
Section titled “Restore”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:
$ sudo apt install mariadb-serverIn the case of CentOS:
$ sudo yum install mariadb-serverAnd 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:
$ unzip /path/to/backup/okm-backup.zip -d /path/to/restore $ mysql -h localhost -u root -p okmdb < /path/to/restore/okmdb.sqlSet the permissions according to the user who starts OpenKM:
$ sudo chown openkm:openkm /path/to/openkm -RInstall the required dependencies. In the case of Ubuntu:
$ sudo apt install xvfb imagemagick libreoffice tesseract-ocrIn the case of CentOS:
$ sudo yum install ImageMagick tesseract libreoffice libreoffice-headlessOnce restored, verify file permissions, start OpenKM, and perform a repository check. See Repository checker.
Windows detailed steps
Section titled “Windows detailed steps”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.
Backup
Section titled “Backup”- Stop the OpenKM service
- Create a database backup
- In case of MariaDB, please visit Full Backup and Restore with Mariabackup
- In case of PostgreSQL, please visit PostgreSQL Backup and Restore
- In case of SQL Server, please visit Create a Full Database Backup
- In case of MySQL, please visit MySQL Backup and Recovery
- Create a backup of the Tomcat folder
- Start the OpenKM service again
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.
Restore
Section titled “Restore”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:
C:\> unzip okm-backup.zip -d C:\C:\> mysql -h localhost -u root -p okmdb < okmdb.sqlSet the permissions according to the user who starts OpenKM.
Once restored, verify file permissions, start OpenKM, and perform a repository check. See Repository checker.
Backup scripts
Section titled “Backup scripts”- Linux backup and restore with BorgBackup (recommended)
- Linux backup and restore with rdiff-backup tool
- Linux backup and restore with rsync
- Linux backup and restore with Duplicity
- Linux backup with LFTP