Backup restoring

From OpenKM Documentation
Revision as of 19:44, 19 December 2012 by Jllort (talk | contribs)

Jump to: navigation, search

In cause of a hardware failure you may need to restore a backup. Backups are very important for OpenKM because you store a lot of documentation on it.


Nota clasica.png This guide is for OpenKM 6.x but if you are using OpenKM 5.x you should read Backup restoring 5.x.

First of all, we need to locate the right backup. OpenKM bacnkup can be done using several specific backup applications, but in Linux the most common used are rsync, rdiff-backup and duplicity.

rsync

In case of rsync you can list with:

$ ls -ld /path/to/backup/*
drwxr-xr-x 4 root root 4096 sep 11 05:00:19 2012 2012-09-11T05:00:19
drwxr-xr-x 4 root root 4096 sep  4 00:00:18 2012 2012-09-04T00:00:18
drwxr-xr-x 4 root root 4096 aug 28 00:00:13 2012 2012-08-28T00:00:13
drwxr-xr-x 4 root root 4096 aug 21 00:00:14 2012 2012-08-21T00:00:14
drwxr-xr-x 4 root root 4096 aug 14 00:00:16 2012 2012-08-14T00:00:16
drwxr-xr-x 4 root root 4096 aug  7 00:00:12 2012 2012-08-07T00:00:12
drwxr-xr-x 4 root root 4096 jul 31 00:00:13 2012 2012-07-31T00:00:13
drwxr-xr-x 4 root root 4096 jul 29 10:36:39 2012 2012-07-29T10:36:39

Then we have decided to restore the backup of made on aug 28 00:00:13 2012:

$ cp /path/to/backup/2012-08-28T00:00:13 /path/to/destination

See rsync documentation for more info.

rdiff-backup

In case of rdiff-backup you can list with:

$ rdiff-backup --list-increment-sizes /path/to/backup
Sun Sep 11 05:00:19 2012         4.25 GB           4.25 GB   (current mirror)
Sun Sep  4 00:00:18 2012         13.3 MB           4.26 GB
Sun Aug 28 00:00:13 2012          674 MB           4.92 GB
Sun Aug 21 00:00:14 2012         5.50 MB           4.93 GB
Sun Aug 14 00:00:16 2012         1.75 MB           4.93 GB
Sun Aug  7 00:00:12 2012          288 KB           4.93 GB
Sun Jul 31 00:00:13 2012         43.0 KB           4.93 GB
Fri Jul 29 10:36:39 2012         5.56 KB           4.93 GB

Then we have decided to restore the backup of made on Sun Aug 28 00:00:13 2012:

$ rdiff-backup --restore-as-of 2012-08-28 /path/to/backup /path/to/destination

The --restore-as-of parameter accepts several formats. See rdiff-backup documentation for more info.

duplicity

In case of duplicity you can list with:

$ duplicity collection-status /path/to/backup
Sun Sep 11 05:00:19 2012         4.25 GB           4.25 GB   (current mirror)
Sun Sep  4 00:00:18 2012         13.3 MB           4.26 GB
Sun Aug 28 00:00:13 2012          674 MB           4.92 GB
Sun Aug 21 00:00:14 2012         5.50 MB           4.93 GB
Sun Aug 14 00:00:16 2012         1.75 MB           4.93 GB
Sun Aug  7 00:00:12 2012          288 KB           4.93 GB
Sun Jul 31 00:00:13 2012         43.0 KB           4.93 GB
Fri Jul 29 10:36:39 2012         5.56 KB           4.93 GB

Then we have decided to restore the backup of made on Sun Aug 28 00:00:13 2011:

$ duplicity restore --restore-time 2012-08-28 /path/to/backup /path/to/destination

The --restore-time parameter accepts several formats. See duplicity documentation and Duplicity Backup Howto for more info.


Nota clasica.png The default OpenKM installation uses an embedded database called Hipersonic. So, the db directory may not exists, because all the needed info is under the tomcat-7.0.27 directory. Refer to Using OpenKM with other databases for more info.

Inside of /path/to/destination you should see a directory /home/openkm, and inside it a couple of directories:

  • db: The backup of the database.
  • tomcat-7.0.27: The backup of the Tomcat installation.

In case you have a MySQL database configured, these are the steps:

DROP DATABASE IF EXISTS okmdb_bak;
CREATE DATABASE okmdb_bak DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_bin;
GRANT ALL ON okmdb_bak.* TO openkm@localhost WITH GRANT OPTION;

Nota clasica.png We have already created a openkm user when the database was created on OpenKM installation. If you want to restore the backuped database in another MySQL installation you will need to create this user. Refer to MySQL-OpenKM 6.2 for more info.

Now restore the previous backup to this new database:


Nota advertencia.png Be careful and don't restore the data into the wrong database because you can damage your current OpenKM installation.

$ mysql -h localhost -u openkm -p okmdb_bak < db/mysql_okmdb.sql

Copy the tomcat-7.0.27 to /home/openkm/tomcat-7.0.27_bak and modify these configuration files to use the new backuped database:

  • conf/server.xml

Stop the current Tomcat (from /home/openkm/tomcat-7.0.27) and start the new one (/home/openkm/tomcat-7.0.27_bak). Log into the restored OpenKM and make a Repository export from Administration. Once completed, stop the backuped Tomcat and start the original one. Then go to Administration > Repository import and import the desired content.


Nota idea.png In case of a complete restore from backup, you don't need to create the okmdb_bak database nor modify and start the backuped Tomcat.