Version 1.1 by Normann P. Nielsen on 2026/11/15 15:43

Hide last authors
Normann P. Nielsen 1.1 1 This article describes the way to make a Disaster Recovery Site of a Confluence Installation
2
3 {{toc/}}
4
5 = Assumptions taken below =
6
7 |= What|= Where
8 | [[Confluence Installation Directory>>https://confluence.atlassian.com/display/DOC/Confluence+Installation+Directory]]| /opt/confluence
9 | [[Confluence Home Directory>>https://confluence.atlassian.com/display/DOC/Confluence+Home+Directory]]| /opt/confluence-data
10 | MySQL Backup| Setup and working, backing up to /backup/mysqlbackup/
11 | Disaster Recovery (Stand by) Server DNS name| drserver.site.dk
12 | [[rsync between servers>>http://troy.jdmz.net/rsync/index.html]]| Setup and working via SSH keys
13
14
15
16 = rsyncing MySQL, Confluence Installation and Confluence Home Files =
17
18 The MySQL backup of the Confluence database and the files of the installation must be syncronised to the alternate server (called drserver.site.dk)
19
20 This should be run with cron in regular intervals
21
22
23 {{code}}
24 #!/bin/bash
25 rsync -avz /backup/mysqlbackup/confluence.sql.gz drserver.site.dk:/mysqlbackup/ >/dev/null
26 rsync -avz /opt/confluence-data --exclude *.log drserver.site.dk:/opt/
27 rsync -avz /opt/confluence --exclude catalina.out drserver.site.dk:/opt/
28 {{/code}}
29
30
31
32 = Scripts and files =
33
34 Script for dropping and creating a new database
35
36
37 {{code language="/scripts/CreateConfluenceDatabase.sql"}}
38 drop database confluence;
39 create database confluence CHARACTER SET utf8 COLLATE utf8_bin;
40 grant all privileges on confluence.* to confluence@localhost identified by 'confconf';
41 flush privileges;
42 {{/code}}
43
44
45
46 = Why change the server.xml and setenv.sh =
47
48 Due to the fact this (problably) is a DR site, some facts can be:
49
50 * The HW specs are lower
51 * The URL (and hence Base URL) are different
52 So we want to change the server.xml and setenv.sh to reflect those changes, otherwise the system may never start correctly.
53
54 So, make a copy of :
55
56
57 {{code}}
58 scp /opt/confluence/conf/server.xml drsite.server.dk:/scripts/server.xml.confluence
59 scp /opt/confluence/bin/setenv.sh drsite.server.dk:/scripts/setenv.sh.confluence
60 {{/code}}
61
62 Now, change the files as needed.
63
64
65
66 = Restore Confluence script =
67
68 This is the script that restores the Confluence on the DR server drserver.site.dk - It needs the files from above to work.
69
70
71 {{code}}
72 #!/bin/bash
73
74 if [ `id | grep "uid=0(root)" | wc -l` -lt 1 ]
75 then
76 echo "must be executed as root"
77 exit 1
78 fi
79
80
81 if [ -f /mysqlbackup/confluence.sql ]
82 then
83 rm /mysqlbackup/confluence.sql
84 fi
85
86
87 echo "Unpacking Confluence database backup"
88 gunzip -c /mysqlbackup/confluence.sql.gz > /mysqlbackup/confluence.sql
89  
90 echo "Dropping and Creating Confluence and JIRA databases"
91 mysql -uroot -password < /scripts/CreateConfluenceDatabase.sql
92
93
94 echo "Importing Confluence database backup into MySQL - This takes a while..."
95 mysql -uroot -password < /mysqlbackup/confluence.sql
96
97
98 if [ $? -eq 0 ]
99 then
100 echo "Import finished ok"
101 else
102 echo "mysql client ended with exit code different from 0. Stopping script"
103 exit 1
104 fi
105
106 echo "Copying server.xml and setenv.sh to Confluence configuration"
107 cp /scripts/server.xml.confluence /opt/confluence/conf/server.xml
108 cp /scripts/setenv.sh.confluence /opt/confluence/bin/setenv.sh
109 rm /opt/confluence/logs/catalina.out
110
111 echo "Ready for Starting Confluence for http://drserver.site.dk"
112 echo "Start with: /opt/confluence/bin/startup.sh;tail -f /opt/confluence/logs/catalina.out"
113 {{/code}}