==================
Backup and Restore
==================

Full Backup / Restore
=====================

The best way to recover from data loss is to have a **full** backup of your machine.
With this backup you can easily restore your machine to a working condition.

The procedure below explains how to selectively back up only the files
essential to your MoinMoin installation. While there is no need to maintain both a full
and a selective backup, having at least one of the two is strongly recommended.

Selective Backup
================
If you want a backup of MoinMoin and your data, then back up the following:

* your data, usually everything under wiki/
* Moin configuration, e.g., wikiconfig.py
* logging configuration, e.g., logging.conf
* Moin deployment script, e.g., moin.wsgi
* web server configuration, e.g., Apache VirtualHost config
* optional: Moin code + dependencies; you should at least know which version
  you ran, so you can reinstall that version when you need to restore

To create a dump of all data stored in MoinMoin (wiki items, user profiles), run the
following command::

 moin save --all-backends --file backup.moin

Please note that this file contains sensitive data like user profiles and wiki
contents, so store your backups in a safe place that no unauthorized
individual can access.

Backups require valid metadata to produce files that can be loaded;
in particular, the size attribute must be correct for each revision.
If bad metadata is found during the backup, a warning will be logged and it is recommended
to run ``moin maint-validate-metadata --all-backends --fix``.
See :ref:`validate-metadata`.

Selective Restore
=================

To restore all software and configuration files to their original
place, create an empty wiki first::

 moin index-create

To load the backup file into your empty wiki, run::

 moin load --file backup.moin

The index is removed and automatically recreated by the load command.
