
Backup and restore
Alternative Languages: 日本語
It is quite easy to create a backup of a Liferay installation, and to restore it later on. A restore of an existing Liferay instance is even useful when setting up a local development environment with existing content.
This backup and restore procedures targets a Liferay 6.0 installation with a MySQL database.
Backup procedure #
- Create a dump of your database, in order to transfer it to another environment. The '-q' option allows for better performance for big environments, as it dumps directly to stdout.
$> mysqldump -u root -p -q lportal > lportal_backup.bak
- Zip the document_library folder, which contains all documents and files from the document library.You don't need the lucene directory, as this can be generated from scratch; based on the DB and document library.
That's it, it couldn't be easier than this!
Restore procedure #
The restore is a bit more complex, but nevertheless still quite easy to perform. We will start with a new database, and import from the dump we've created in the backup procedure.
- Open a connection to your MySQL database and perform the following command:
$mysql> CREATE DATABASE lportal CHARACTER SET UTF8;
- Copy the document_library folder to your Liferay data folder.You can find the location of the document library in
portal-ext.properties: dl.hook.file.system.root.dir
- Import the database backup in your newly created database with following command:
$mysql> mysql -u root -p lportal < lportal_backup.bak
- Start the Liferay server.This would trigger possible automatic migration procedures.
- Regenerate the Lucene index, by navigating to the Control Panel, Server Administration, and than execute the Action: Re-index (this may take a while, depending on the data size of your db/doc-library)
Restore from a different application server (EE only) #
If you are restoring your Liferay instance from a different application server (e.g. from WebSphere to Tomcat), you need to perform following additional steps because the cryptography libraries of the application server may be used to encrypt/decrypt certain data.
You need to perform following steps when getting exceptions that rely to encryption, when trying to perform a login:
- Retrieve the current companyId and accountId from your database, and write them down:
$mysql> SELECT companyId, accountId FROM company;
- Clear the company table that contains they 'key_' in encrypted form, example:
$mysql> DELETE FROM company WHERE companyId=10113 and accountId=10115
- Restart your application server, which will make sure the company table is populated again. It will automatically create a new company when it cannot find the desired one, creating a key that's valid for your new JVM.
- The companyId and accountId will have invalid values. We need to reset them to the values from step 1:
$mysql> UPDATE company SET companyId=10113;
$mysql> UPDATE company SET accountId=10115;
- Restart Liferay once again to make sure all settings are adapted.