Backup/Restore
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.
Backup configuration files
There are several configuration files you'll need to backup:
- WEB-INF/hibernate.cfg.xml (Hibernate configuration)
- WEB-INF/xwiki.cfg (old XWiki configuration file but still used)
- WEB-INF/xwiki.properties (new XWiki Configuration file)
- WEB-INF/classes/logback.xml (Logging configuration)
- WEB-INF/observation/* (Cluster configuration)
To restore them simply copy them at the same location where you backupped them from.
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. For a complete save of the actual state of your wiki (despite the fact that you'll also need to backup your database) , you can backup the entire xwiki webapp directory.
Backup your database
XWiki stores all its data in a database so all you need to do is to backup this database.
If you've installed the default standalone version of XWiki then the data are saved in a Hypersonic SQL database bundled by default. It's located in a data/database directory inside the directory when you installed XWiki. Simply backup this directory and that'll backup all the Hypersonic SQL database.
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 backup a huge amount of data, we advise that you compress the dump files to save disk (for example with gzip).
- MySQL: You can use
mysqldump xwiki > xwiki.sqlto backup the xwiki schema (use the option --all-databases if you're in multiwiki mode) andmysql xwiki --user=root -p < xwiki.sqlto restore it. - PostgreSQL: You can use
pg_dump xwiki > xwiki.sqlto backup PostgreSQL database andpsql -d xwiki -f xwiki.sqlto restore it. In case of multiwiki mode, use the binary pg_dumpall instead. - Oracle: Use exp to export data and imp to restore it.
In case of Filesystem Attachment Storage
Since XWiki 3.x you can choose to store the attachment on the filesystem instead of in a database.
Then, you would need to backup the environment.permanentDirectory directory that is set into xwiki.properties configuration file. See here.
Use the XWiki Import/Export tool
Since all XWiki data are saved in XWiki pages one solution to backup a XWiki instance is simply to export all its pages. This can easily be done using the Import/Export tool. 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 etter to use a specialized backup tool that'll bbackup the database, perform incremental backups, verify backup integrity, etc.
The Import/Export should be reserved for the following use cases:
- move data across XWiki instances, including sharing of applications between separate instances
- move data to another wiki