There is a need to automate the backup of a wiki, or make it easy to export the current state of a wiki to another location.

Configuration

In your wikiconfig.py or farmconfig.py file, add the following:

# Who is allowed to perform remote backup, change this!
#backup_users = ['UserName']

# What to backup
#backup_include = [] # this is the default value, see multiconfig.py

# Backup exclude - each file is matched against this list, any match will 
# be excluded from the backup. By default, cache files, python compiled modules 
# and various temporary files are excluded.
# BE CAREFUL: this stuff is used as a regex and therefore must be valid regexes.
#backup_exclude = [ # this is the default value, see multiconfig.py
#    r"(.+\.py(c|o)$)",
#    r"%(cache_dir)s",
#    r"%(/)spages%(/)s.+%(/)scache%(/)s[^%(/)s]+$" % {'/': os.sep},
#    r"%(/)s(edit-lock|event-log|\.DS_Store)$" % {'/': os.sep},
#]

To get a backup you must be listed in the backup_users section in your wikiconfig.py or farmconfig.py file. You must access the wiki as that logged-in user (e.g. using a browser).

Backup format

You may configure backup_compression (it support everything tarfile supports, if you are unsure just use the default is uses and do no specify it in your wiki configuration).

The link will start to download the backup named wikiname-yyyy-mm-dd--HH-MM-SS-UTC.tar.<backup_compression>

Which format and compression level to use?

Here are timings for backup of a 864 pages, 17MB wiki. Time is the time from clicking the backup link until the download is finished on localhost. Machine: Dual G5 2GHz???

Format

Compression Level

Time

File Size

Gzip

1

7s

1.7MB

Gzip

5

7s

1.4MB

Gzip

9 (Python default)

8s

1.3MB

Bzip2

1

8s

1.2MB

Bzip2

5

11s

1.0MB

Bzip2

9 (Python default)

13s

1.0MB

More timings, for a 400MHz/128MB machine, just compression CPU user time without tar:

Format

Compression Level

Time

File Size

Uncompressed

0

0s

494MB

Gzip

1

83s

98MB

Gzip

3

92s

93MB

Gzip

4

108s

81MB

Gzip

5

128s

79MB

Gzip

9

237s

76MB

Bzip2

1

955s

78MB

Bzip2

5

1303s

57MB

Bzip2

9

1512s

53MB

If you have fast server with a light load and slow connection, go with bzip2 format. If you have slow loaded server and fast connection, use gzip (4).

The results may change if your wiki contains lot of attachments which can not be compressed, for example compressed files, jpeg files etc.

Automating your backups

People would like to setup a cron job to get a daily backup.

This python script should work on any platform:

import webbrowser
webbrowser.open('http://wikidomain/?action=backup')

On Mac OS X, you can use a simpler shell script:

open http://wikiurl?action=backup

You can use wget or curl, but you have to get your cookie to authenticate.

Easy Backup on Windows

Backing up on Windows is accomplished easily with Microsoft Robocopy. Instructions here: RickVanderveer/Win32MoinEasyBackup


Problems

How to start a backup

Putting WikiBackup in the more action menu is a waste of valuable space. 99% of users do not need menu, and can't use it.

A better solution would be a link on the admin page, or maybe a simple form:

Wiki Backup
Options: [x] faster (gzip) [ ] smaller (bzip2)

[[Download Backup]]

And when we are not in the menu, we can use nicer url: ?action=backup

Big wikis

On big wiki, it can be too expensive to create the backup on each call. Maybe create the backup once per day/hours?

The method works on the MoinMoin wiki site, which is relatively large. We will fix that problem if we really encounter it.


Ideas

Get backup with wikirpc

Not implemented yet, but can be done easily. The questions is rather: for what do we need that with wikirpc?

Get backup from date to date

Files can be checked for mtime when collecting them, and only new files can be collected.

This may make a restore harder.

Easy Backups

Some users don't care about state, users etc. (may only have one user) For us, just the content recovery is the goal. Perhaps a list of what the important file(s) to manually backup to achieve that would be would be helpful.

MoinMoin: WikiBackup (last edited 2013-09-12 08:30:57 by warpcore)