JGuru
When you need a guru
  • Home
  • About
  • Services
  • Blog
  • Projects
    • Liferay Backup
    • Photo Carousel Portlet
    • Social Comments Portlet
    • Liferay Yubikey OTP Login
  • Contact
May 28 2012

How to Create a Consistent Liferay Backup

Mika Koivisto Howto backup, liferay 0

This is a question I’ve gotten asked in nearly all the Liferay System Administrator trainings I’ve given. Most people will just backup their database and Liferay data directory separately but any competent system admin will tell you that it’s not guaranteed to be consistent because someone could upload or delete files between the time you took the database dump and the time you copied the data directory. Now I’m assuming that you are storing your document library binaries to filesystem instead of database.

Now to achieve a consistent backup with minimal interruption to your portal what you need to do is get a read lock on all your Liferay tables. This will prevent writes to the database. Then you dump the database to file with a tool like mysqldump and then you take a quick snapshot of the filesystem before you unlock the tables. You need to keep the connection that locked the tables open until this whole process is done. Once you have the database dump and filesystem snapshot ready only then you can release the lock and then you can backup the data directory using what ever method you would normally use.

For the PoC I’m using MySQL and my filesystem is on Linux LVM volume which supports taking snapshots. I’ve written a Perl script to execute all the commands. I’m sharing the script under GPL and it’s available in Github. Feel free to fork it and modify it to suit your needs and if you have good ideas send me a pull request.

The way the script works is you pass in bunch of parameters like database details, lvm volume location, source and target directories. Here’s an example:

backup_liferay.pl -u dba-backup -p mypassword -d lportal -h localhost \
--lvm-volume-path /dev/vg0/opt --lvm-snapshot-volume-path /dev/vg0/opt-snapshot \
--lvm-snapshot-volume-name opt-snapshot --lvm-snapshot-volume-size 50G \
--snapshot-mount-path /backups/snapshot \
--source-path /liferay-portal-6.1.0/data/document_library \
--db-target-path /backups/mysql/lportal.sql.gz \
--data-target-path /backups/liferay --compress

Now even if that doesn’t exactly match your system I hope it gives you an idea how to roll your own Liferay backup.

Share this:

  • Tweet
  • Share on Tumblr
Debugging Maven Plugins What to Do When You Get “Error listerStart” with Tomcat

Related Posts

cyber_security

Howto

How to get Tomcat to see HTTPS when it’s terminated elsewhere

nginx

Howto

Creating a custom Nginx build for Ubuntu/Debian

getting-git-right

Howto

Moving a project from one git repository to another while retaining it’s history

Tags

activemq apache backup c3p0 certificate connection pool debian debugging deployment git heap hook httpd https installer java jms jmx jmx4perl jndi jolokia jvm liferay mariadb maven memory monitoring mrtg mysql nagios newrelic nginx ngx_cache_purge pagespeed performance repository salesforce saml security spring ssl struts tls tomcat ubuntu

Categories

  • General
  • Howto
  • Liferay

Recent Posts

  • cyber_securityHow to get Tomcat to see HTTPS when it’s terminated elsewhere
  • failTop 3 reasons why Liferay projects fail
  • FIDO-Yubico-YubiKeys-2-444x296Liferay Yubikey OTP Login
  • nginxCreating a custom Nginx build for Ubuntu/Debian
  • getting-git-rightMoving a project from one git repository to another while retaining it’s history

Archives

  • October 2017
  • February 2017
  • January 2017
  • July 2016
  • June 2016
  • May 2016
  • August 2015
  • April 2015
  • January 2015
  • October 2013
  • June 2013
  • August 2012
  • July 2012
  • June 2012
  • May 2012
  • March 2012
  • February 2012
  • January 2012
  • January 2011
  • September 2010
  • August 2010
  • December 2009
  • October 2008
  • December 2007

Recent Posts

  • cyber_securityHow to get Tomcat to see HTTPS when it’s terminated elsewhere
  • failTop 3 reasons why Liferay projects fail
  • FIDO-Yubico-YubiKeys-2-444x296Liferay Yubikey OTP Login
  • nginxCreating a custom Nginx build for Ubuntu/Debian
  • getting-git-rightMoving a project from one git repository to another while retaining it’s history

Follow me on Twitter

My Tweets
© JGuru 2006 - 2017