Is there a solution to automatically backup & restore Confluence?
Asked by C. Faysal:

for Jira i built a script that modifies an existing jiraDBdump:

* change Hostname
* change CrowdServerName
* update License (change to developer)
* rsync $Jira_Home/data (from productive to backup host)
* shut down JIRA
* insert the modified dump into to backup DB
* start Jira

works as expected.

i want to build something similar for confluence.

can this be done the same way? if i take a look at the sqldump (large file) i can tell it is not that easy and comfortable like it is for jira.

any ideas/suggestions on this one?

regards


Answers:
author: Alejandro Conde Carrillo
body: Hi.

I am talking from the top of my head, so take this as a guideline more than a procedure.

If you are usig standalone Confluence, this procedure would make sense for me:

1. Copy data directory
2. Modify database settings and license in the file \<confluence_data\>/confluence.cfg.xml
3. Copy installation directory
4. Modify location of the data directory in \<confluence_install\>/confluence/WEB-INF/classes/confluence-init.properties
5. Change ports in the file \<confluence_install\>/conf/server.xml
6. Restore database dump
7. Chage Server Base URL in the BANDANA table. Bandana Key is atlassian.confluence.settings and the value is withing the XML.
8. To avoid problems on startup I would [clear the plugin cache](https://confluence.atlassian.com/display/CONFKB/How+to+Clear+Confluence+Plugins+Cache "How to Clear Confluence Plugins Cache").

After that procedure, you should be able to start Confluence. Please remember that I haven't tested this procedure, but I believe that should make it. You can probably simplify it if you use the same paths and ports.

comments: author: C. Faysal
body: Hi alex. Thanks for participatin.I didn't knew the license could be changed that way. Also i already found the kb article about how to change server base url manually. Is there no other than update the entire xml block?


author: Alejandro Conde Carrillo
body: You could replace the string directly in the DB, many DB servers offer options for replace a string withing a field.


author: C. Faysal
body: hi alex.

can you please tell me why inside atlassian.confluence.settings the \<webdavPassword\> is in plaintext?

what is \<webdavuser\> used for ?


author: C. Faysal
body: ok i got my script cloning confluence on a backup host now. :)

confluenceSQLdump and data/attachment DIR is synced via cron hourly to the backup host

here are the steps it does:

1. unzip the dump
2. stop confluence
3. insert the dump
4. execute two queries  

   ```
   mysql -u&lt;user&gt; -p&lt;pwd&gt; confluence -e "UPDATE cwd_directory_attribute SET attribute_value =  REPLACE(attribute_value, '&lt;old_hostname&gt;' , '&lt;new_hostname&gt;')"        mysql -u&lt;user&gt; -p&lt;pwd&gt; confluence -e "UPDATE BANDANA SET BANDANAVALUE = REPLACE(BANDANAVALUE, '&lt;old_hostname&gt;', '&lt;new_hostname&gt;') where BANDANACONTEXT = '_GLOBAL' and BANDANAKEY = 'atlassian.confluence.settings'"
   ```

5. sync data/attachments directory
6. clean plugins cache
7. start confluence


author: Renjith Pillai
body: <https://confluence.atlassian.com/display/DOC/Confluence+Cluster+Installation> ?

comments: author: C. Faysal
body: Thx renjith. I know about cluster license. But at the moment my company is not planing to buy some. Thatswhy i was tryin to create something else


Tags: automation

backup

restore