Wiki source code of Backup/Restore

Version 13.2 by Manuel Smeria on 2012/12/12

Hide last authors
Thomas Steinbach 5.3 1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
Ludovic Dubost 5.1 4
Vincent Massol 10.4 5 It's crucial that you define a backup strategy for your wiki so that you don't lose any data in case of a problem with your wiki installation or in case you have issues upgrading your XWiki instance to a newer version.
Vincent Massol 1.1 6
Silvia Macovei 5.2 7 = Backup configuration files =
Vincent Massol 1.1 8
Vincent Massol 8.3 9 There are several configuration files you'll need to backup:
Ludovic Dubost 4.1 10
Vincent Massol 8.3 11 * ##WEB-INF/hibernate.cfg.xml## (Hibernate configuration)
12 * ##WEB-INF/xwiki.cfg## (old XWiki configuration file but still used)
13 * ##WEB-INF/xwiki.properties## (new XWiki Configuration file)
14 * ##WEB-INF/classes/logback.xml## (Logging configuration)
15 * ##WEB-INF/observation/*## (Cluster configuration)
Vincent Massol 1.1 16
Manuel Smeria 13.2 17 To restore them simply copy them at the same location where you backed them up from.
Vincent Massol 1.1 18
Vincent Massol 10.3 19 In addition you may want to also backup any extra files you'll have installed in your XWiki installation such as JDBC drivers, extra plugins, etc.
Guillaume Fenollar 8.1 20
Vincent Massol 10.1 21 = Backup Permanent Data =
Vincent Massol 1.1 22
Vincent Massol 10.1 23 XWiki generates the following data:
24 * Wiki pages (they're saved in a Database)
Vincent Massol 11.1 25 * Attachments on the filesystem
Vincent Massol 10.1 26 * Installed extensions
27 * Lucene index files
28 * Logs
Vincent Massol 1.1 29
Vincent Massol 10.1 30 It's important that you back them up.
Vincent Massol 1.1 31
Manuel Smeria 13.2 32 If you've installed the default standalone version of XWiki then all the data is located in the ##data/## directory inside the directory where you've installed XWiki. Simply back up this directory and that'll backup everything. Otherwise, read on below!
Vincent Massol 10.1 33
34 == Backup your database ==
35
Manuel Smeria 13.2 36 If you've installed XWiki using your own database then you'll need a backup tool for that database to back it up and to restore it. Moreover, if you're backing up a huge amount of data, we advise that you compress the dump files to save disk space (for example with [[7-zip>>http://www.7-zip.org/]]).
Vincent Massol 1.1 37
Vincent Massol 13.1 38 * **MySQL**:(((
Manuel Smeria 13.2 39 Backup: {{code}}mysqldump --add-drop-database --databases xwiki > xwiki.sql{{/code}} backs up the xwiki schema (use the option ##~-~-all-databases## instead of ##~-~-databases xwiki## if you're in multiwiki mode)
Vincent Massol 13.1 40 Restore: {{code}}mysql xwiki --user=root -p < xwiki.sql{{/code}}
41
42 {{warning}}
Manuel Smeria 13.2 43 It's important that the backup is done with ##~-~-add-drop-database## since when you restore it it's important that tables that might have been created are removed. For example database migrations can create extra tables. If you want to cancel the migration and go back to your clean dump you'll need to have those tables removed as otherwise when you run the migration again later on you might have errors.
Vincent Massol 13.1 44 {{/warning}}
45 )))
Manuel Smeria 13.2 46 * **PostgreSQL**: You can use {{code}}pg_dump xwiki > xwiki.sql{{/code}} to backup the PostgreSQL database and {{code}}psql -d xwiki -f xwiki.sql{{/code}} to restore it. In case of multiwiki mode, use the binary ##pg_dumpall## instead.
Vincent Massol 9.1 47 * **Oracle**: Use ##exp## to export data and ##imp## to restore it.
Vincent Massol 1.3 48
Vincent Massol 10.1 49 == Backup Attachments ==
Guillaume Fenollar 8.1 50
Manuel Smeria 13.2 51 Since XWiki 3.x you can choose to [[store attachments on the filesystem>>AdminGuide.Attachments#HAttachmentStorage]] instead of in the database. If you've configured it this way then you need to backup the Permanent Directory which is where attachments saved on the filesystem are located. This directory is configured by the ##environment.permanentDirectory## configuration property in your ##WEB-INF/xwiki.properties## configuration file.
Guillaume Fenollar 8.1 52
Vincent Massol 10.1 53 == Backup Extensions ==
Guillaume Fenollar 8.1 54
Vincent Massol 10.1 55 Extensions are also saved on the filesystem in the Permanent Data Directory (i.e. ##environment.permanentDirectory##) in an ##extension## subdirectory.
56
57 == Backup Lucene index files ==
58
59 You could decide to backup Lucene index files. However XWiki will regenerate them automatically if they are not found at startup. Now if you have a lot of wiki pages that can take a lot of time and you may want to back them up. They are also located in the Permanent Data Directory (i.e. ##environment.permanentDirectory##) in a ##lucene## subdirectory.
60
61 == Backup Log files ==
62
Manuel Smeria 13.2 63 XWiki generates logs in the console by default and these will go where your Servlet container has been defined to save them. For Tomcat for example this usually goes in the ##TOMCAT_HOME/logs/catalina.out## file.
Vincent Massol 10.1 64
65 However this is fully [[configurable>>AdminGuide.Logging]] and you may have configured XWiki to output log files elsewhere. If you want to keep those logs, don't forget to save them. Those logs are not needed by XWiki but you may want to save them to review them later on to diagnose issues that happened for example.
66
Vincent Massol 10.5 67 = Using the XWiki Export feature =
Vincent Massol 1.1 68
Vincent Massol 10.1 69 Since most XWiki data is saved in wiki pages one solution to backup a XWiki instance is to export all its pages using XWiki's [[Import/Export feature>>ImportExport]]. However note that this is quite a resource hungry operation and depending on the size of your wiki you may need a lot of memory. As a consequence the recommended backup strategy is to backup the databases. It's much better to use a specialized backup tool that'll backup the database, perform incremental backups, verify backup integrity, etc.
Vincent Massol 1.1 70
Vincent Massol 10.1 71 In addition you should know that currently the following information is not located in wiki pages and is thus not saved in a wiki export:
72 * Activity stream data
73 * Statistics data
74 * Feed plugin data (if you use it)
75 * Deleted documents/attachments data
Ludovic Dubost 4.1 76
Vincent Massol 10.1 77 Moreover this won't save configuration data or other Permanent Data mentioned above such as installed Extensions, Lucene index files and Logs.
78
Manuel Smeria 13.2 79 In practice the Import/Export feature should be reserved for the following use cases:
Vincent Massol 1.5 80 * move data across XWiki instances, including sharing of applications between separate instances
81 * move data to another wiki

Get Connected