This article describes the way to make a Disaster Recovery Site of a Confluence Installation

Assumptions taken below

Confluence Installation Directory/opt/confluence
Confluence Home Directory


MySQL BackupSetup and working, backing up to /backup/mysqlbackup/
Disaster Recovery (Stand by) Server DNS name

rsync between serversSetup and working via SSH keys


rsyncing MySQL, Confluence Installation and Confluence Home Files

The MySQL backup of the Confluence database and the files of the installation must be syncronised to the alternate server (called

This should be run with cron in regular intervals

rsync -avz /backup/mysqlbackup/confluence.sql.gz >/dev/null
rsync -avz /opt/confluence-data --exclude *.log
rsync -avz /opt/confluence --exclude catalina.out


Scripts and files

Script for dropping and creating a new database

drop database confluence;
create database confluence CHARACTER SET utf8 COLLATE utf8_bin;
grant all privileges on confluence.* to confluence@localhost identified by 'confconf';
flush privileges;


Why change the server.xml and

Due to the fact this (problably) is a DR site, some facts can be:

  • The HW specs are lower
  • The URL (and hence Base URL) are different

So we want to change the server.xml and to reflect those changes, otherwise the system may never start correctly.

So, make a copy of :

scp /opt/confluence/conf/server.xml
scp /opt/confluence/bin/

Now, change the files as needed.


Restore Confluence script

This is the script that restores the Confluence on the DR server - It needs the files from above to work.


if [ `id | grep "uid=0(root)" | wc -l` -lt 1 ]
	echo "must be executed as root"
	exit 1

if [ -f /mysqlbackup/confluence.sql ]
	rm /mysqlbackup/confluence.sql

echo "Unpacking Confluence database backup"
gunzip -c /mysqlbackup/confluence.sql.gz > /mysqlbackup/confluence.sql
echo "Dropping and Creating Confluence and JIRA databases"
mysql -uroot -password < /scripts/CreateConfluenceDatabase.sql

echo "Importing Confluence database backup into MySQL - This takes a while..."
mysql -uroot -password < /mysqlbackup/confluence.sql

if [ $? -eq 0 ]
	echo "Import finished ok"
	echo "mysql client ended with exit code different from 0. Stopping script"
	exit 1

echo "Copying server.xml and to Confluence configuration"
cp /scripts/server.xml.confluence /opt/confluence/conf/server.xml
cp /scripts/ /opt/confluence/bin/
rm /opt/confluence/logs/catalina.out

echo "Ready for Starting Confluence for"
echo "Start with: /opt/confluence/bin/;tail -f /opt/confluence/logs/catalina.out"