Manual:Backing up a wiki/de
Es ist wichtig, regelmäßige Sicherungen (engl.: Backup, pl.: Backups) der Daten in ihrem Wiki zu machen. Diese Seite bietet einen Überblick über den Sicherungsvorgang für einen typischen MediaWiki-Wiki; möglicherweise möchten Sie Ihre eigenen Sicherungsskripte oder Zeitpläne anlegen, die an die Größe Ihres Wikis und Ihre individuellen Bedürfnisse angepasst sind.
Contents
Übersicht[edit | edit source]
MediaWiki speichert wichtige Daten an zwei Orten:
- Datenbank
- Seiten und ihr Inhalt, Benutzer und ihre Einstellungen, Metadaten, den Suchindex usw.
- Dateisystem
- Konfigurationsdateien, angepasste Skins, Erweiterungen, Bilder (inkl. gelöschte Bilder) usw.
Consider making the wiki read-only before creating the backup - see $wgReadOnly. This makes sure all parts of your backup are consistent (some of your installed extensions may write data nonetheless).
Datenübertragung[edit | edit source]
Für die Übertragung des Backups vom Server stehen folgende Möglichkeiten zur Verfügung:
Nicht-private Daten können einfach auf archive.org veröffentlicht und/oder in einem dumps/
-Verzeichnis Ihres Servers abgelegt werden.
SCP (or WinSCP), SFTP/FTP oder irgend ein anderes Übertragungsprotokoll, mit dem sie vertraut sind, ist verfügbar.
Ihr Webspace-Betreiber stellt Ihnen vielleicht sogar eine Datei-Manager-Oberfläche über Ihren Webbrowser zur Verfügung. Klären Sie das mit ihm ab.
Datenbank[edit | edit source]
Die meisten wichtigen Daten des Wikis werden in der Datenbank gespeichert, die i.d.R. sehr leicht zu sichern ist. Wenn Sie das MySQL-Backend benutzen (standardmäßig), stehen Ihnen verschiedene Tools zur Verfügung, um die Datenbank in eine Datei zu "dumpen" (engl. dumping, bedeutet soviel wie "exportieren"). Die dadurch erzeugte Skriptdatei kann verwendet werden, um die Datenbank von Grund auf neu einzurichten.
MySQL[edit | edit source]
Es gibt auch andere Tools, wie zum Beispiel das (kommerzielle) MySQL-Hot-Backup-Utility, das InnoDB-Tabellen während der Laufzeit sichern kann, sowie das bekannte Open-Source-Tool phpMyAdmin, eine webbasierte Anwendung, die zahlreiche Funktionen bietet, um mit einer MySQL-Datenbank zu arbeiten, darunter eben auch ein ausführliches Tool zum Exportieren (Dumpen) von Datenbanken.
The most convenient way to create a dump file of the database you want to back up is to use the standard MySQL dump tool mysqldump from the command line. Be sure to get the parameters right or you may have difficulty restoring the database. Depending on database size, mysqldump could take a considerable amount of time.
Fügen Sie zunächst die folgende Zeile in die Datei LocalSettings.php ein
$wgReadOnly = 'Dumping Database, Access will be restored shortly';
Diese Zeile kann wieder entfernt werden, sobald die Sicherung abgeschlossen ist.
Ein beispielhafter Aufruf von der Linux/UNIX Kommandozeile:
mysqldump -h hostname -u userid --password --default-character-set=whatever dbname > backup.sql
Verwenden Sie individuellen Werte für hostname, userid, character-set, dbname. Durch dieses Skript wird eine Sicherungsdatei mit dem Wochentag im Dateinamen erstellt, so dass Sie ein fortlaufendes Set von Datensicherungen haben. Wenn Sie die Dateien und Erweiterungen ebenfalls speichern möchten, könnten Sie zum Beispiel dieses Tool benutzen.
Wenn die letzte Zeile keinen DEFAULT CHARSET-Teil enthält und Sie wissen, dass der Zeichensatz von niemandem verändert wurde, seit die Datenbank eingerichtet wurde, und dass die Wiki-Datenbank mit dem Standard-Zeichensatz der Datenbank erstellt wurde, dann gibt es noch einen anderen Weg, den Zeichensatz herauszufinden: Der STATUS-Befehl zeigt den Standard-Zeichensatz des Datenbankservers (bei Server characterset:). Hier eine Beispielausgabe:
Benutzen Sie die Option --default-character-set=latin1 in der mysqldump-Kommandozeile, um die Zeichensatzkonvertierung zu verhindern, sofern der o.g. Standardzeichensatz auf "latin1" eingestellt ist.
für MySQL 4.1 und jüngere Versionen: Bei einigen allgemeinen Konfigurationen könnte mysqldump die in der Datenbank gespeicherten Artikeltexte beschädigen. Wenn der Zeichensatz Ihrer Datenbank auf "latin1" statt "UTF-8" gesetzt ist, wird mysqldump eine Zeichensatzkonvertierung durchführen, die beispielsweise Umlaute im Text zerstören könnte.
Das MySQL-Dump-Tool beispielsweise ist ein Kommandozeilenprogramm, das eine Dump-Datei mit dem Namen der Datenbank(en) erzeugen kann. Das Programmverhalten kann durch Standard-Parameter verändert werden, die das Format der Ausgabedatei z.B. durch Setzen des Zeichensatzes anpassen.
Sie können sich ansehen, welchen Zeichensatz Ihre Tabellen benutzen, wenn Sie einen MySQL-Befehl wie SHOW CREATE TABLE text verwenden. Die letzte Zeile wird dann einen DEFAULT CHARSET-Teil enthalten.
The output from mysqldump can instead be piped to gzip, for a smaller output file, as follows
mysqldump -h hostname -u userid --password dbname | gzip > backup.sql.gz
A similar mysqldump command can be used to produce xml output instead, by including the --xml parameter.
mysqldump -h hostname -u userid --password --xml dbname > backup.xml
and to compress the file with a pipe to gzip
mysqldump -h hostname -u userid --password --xml dbname | gzip > backup.xml.gz
Remember to also backup the file system components of the wiki that might be required, eg. images, logo, and extensions.
Running mysqldump with Cron[edit | edit source]
Cron is the time-based job scheduler in Unix-like computer operating systems. Cron enables users to schedule jobs (commands or shell scripts) to run periodically at certain times or dates.
Zum Beispiel so:
nice -n 19 mysqldump -u $USER --password=$PASSWORD $DATABASE -c | nice -n 19 gzip -9 > ~/backup/wiki-$DATABASE-$(date '+%Y%m%d').sql.gz
The nice -n 19
lowers the priority of the process.
Use valid values for $USER
, $PASSWORD
, and $DATABASE
. This will write a backup file with the weekday in the filename so you would have a rolling set of backups. If you want to save the files and extensions as well, you might want to use this one.
![]() |
Do not attempt to back up your Mediawiki database using mysqlhotcopy. The table format used by Mediawiki cannot be backed up with this tool, and it will fail silently! |
If you want to add this task in Cron through Cpanel then you must escape the character "%"
/usr/bin/mysqldump -u $USER --password=$PASSWORD $DATABASE -c | /bin/gzip > ~/backup/wiki-$DATABASE-$(date '+\%Y\%m\%d').sql.gz
or you will get an error:
/bin/sh: -c: line 0: unexpected EOF while looking for matching `'' /bin/sh: -c: line 1: syntax error: unexpected end of file
Tables[edit | edit source]
Under close examination one finds that some of the tables dumped have various degrees of temporariness. So to save disk space (beyond just gziping), although those tables need to be present in a proper dump, their data does not. However, under certain circumstances the disadvantage of having to rebuild all this data may outweigh the saving in disk space (for example, on a large wiki where restoration speed is paramount).
See mailing list thread mysql5 binary schema about the topic.
Latin-1 to UTF-8 conversion[edit | edit source]
See the relevant section of the upgrading page for information about this process. Also see the talk page for more information about working with character sets in general.
PostgreSQL[edit | edit source]
You can use the pg_dump
tool to back up a MediaWiki PostgreSQL database. For example:
pg_dump mywiki > mywikidump.sql
will dump the mywiki
database to mywikidump.sql.
To restore the dump:
psql mywiki -f mywikidump.sql
You may also want to dump the global information, e.g. the database users:
pg_dumpall --globals > postgres_globals.sql
SQLite[edit | edit source]
If your wiki is currently offline, its database can be backed up by simply copying the database file. Otherwise, you should use a maintenance script: php maintenance/sqlite.php --backup-to <backup file name>
, which will make sure that operation is atomic and there are no inconsistencies. If your database is not really huge and server is not under heavy load, users editing the wiki will notice nothing but a short lag. Users who are just reading will not notice anything in any case.
phpMyAdmin[edit | edit source]
Turn your wiki to read only by adding $wgReadOnly = 'Site Maintenance';
to LocalSettings.php.
Open the browser to your phpadmin link, login, choose the wiki database. (Check LocalSettings.php if you're not sure). Select Export. Make sure all items under Export are highlighted, and make sure Structure is highlighted (it's important to maintain the table structure). Optionally check Add DROP TABLE to delete existing references when importing. Make sure Data is checked. Select zipped. Then click on GO and save the backup file.[1]
Remove $wgReadOnly = 'Site Maintenance';
from LocalSettings.php
Remember to also backup the file system components of the wiki that might be required, eg. images, logo, and extensions.
External links[edit | edit source]
- Für ein sehr gut geschriebenes Tutorial (einer Anleitung), schaue bei der Internetseite Siteground vorbei und lese: MySQL Export: Wie sichert man eine MySQL-Datenbank mit phpMyAdmin
HeidiSQL[edit | edit source]
HeidiSQL is similar to phpMyAdmin, but without any restrictions of phpMyAdmin's free version.
Dateisystem[edit | edit source]
MediaWiki stores other components of the wiki in the file system where this is more appropriate than insertion into the database, for example, site configuration files (LocalSettings.php
, AdminSettings.php
), image files (including deleted images, thumbnails and rendered math and SVG images, if applicable), skin customisations, extension files, etc.
Der beste Weg, diese Dateien zu sichern, liegt darin, sie in eine Archivdatei zu packen, die zum Beispiel das .tar-Format hat; eine Kompression ist bei Bedarf möglich. Unter Windows können dazu Programme wie WinZip verwendet werden.
For Linux variants, assuming the wiki is stored in /srv/www/htdocs/wiki
tar zcvhf wikidata.tgz /srv/www/htdocs/wiki
It should be possible to backup the entire "wiki" folder in "htdocs" if using XAMPP.
Backup the content of the wiki (XML dump)[edit | edit source]
It is also a good idea to create an XML dump in addition to the database dump. XML dumps contain the content of the wiki (wiki pages with all their revisions), without the site-related data (they do not contain user accounts, image metadata, logs, etc).[2]
XML dumps are less likely to cause problems with character encoding, as a means of transfering large amounts of content quickly, and are easily be used by third party tools, which makes XML dumps a good fallback should your main database dump become unusable.
To create an XML dump, use the command-line tool dumpBackup.php
, located in the maintenance
directory of your MediaWiki installation. See Manual:dumpBackup.php for more details.
Sie können auch für einen Teil der Seiten online einen XML-Dump erstellen, indem Sie die Export-Spezialseite (Special:Export) benutzen, auch wenn der Versuch, größere Textmengen oder längere Versionengeschichten mit diesem Tool zu sichern, meistens an einem Timeout scheitert.
To import an XML dump into a wiki, use the command-line tool importDump.php
. For a small set of pages, you can also use the Special:Import page via your browser (by default, this is restricted to the sysop group). As an alternative to dumpBackup.php
and importDump.php
, you can use MWDumper, which is faster, but requires a Java runtime environment.
See Manual:Importing XML dumps for more information.
Without shell access to the server[edit | edit source]
If you have no shell access, then use the WikiTeam Python script dumpgenerator.py from a DOS, Unix or Linux command-line. To run the script see the WikiTeam tutorial.
See also Meta:Data dumps.
Skripts[edit | edit source]
![]() |
* Inoffizielles Sicherungsskript von Duesentrieb: [1]; erstellt eine Sicherung aller Dateien, einen Datenbank- und einen XML-Dump. Verwendung auf eigene Gefahr (was ja eigentlich auf das ganze MediaWiki zutrifft). |
- Unofficial backup script by Flominator; creates a backup of all files and the database, with optional backup rotation.
- User:Darizotas/MediaWiki Backup Script for Windows - a script for backing up a Windows MediaWiki install. Note: Has no restore feature.
- Unofficial web-based backup script, mw_tools, by Wanglong (allwiki.com); you can use it to back up your database, or use the backup files to recover the database, the operation is very easy.
- WikiTeam tools - if you do not have server access (e.g. your wiki is in a free wikifarm), you can generate an XML dump and an image dump using WikiTeam tools (see some saved wikis)
- Another backup script that: dumps DB, files, and XML; puts the site into read-only mode; timestamps backups; and reads the charset from LocalSettings. Script does not need to be modified for each site to be backed up. Does not (yet) rotate old backups. Usage:
backup.sh -d backup/directory -w installation/directory
- Script to make periodical backups mw_backup. This script will make daily, weekly and monthly backups of your database and images directory when run as a daily cron job.
Siehe auch[edit | edit source]
- Manual:Restoring a wiki from backup
- Manual:Moving a wiki
- Manual:Upgrading
- Manual:Restoring wiki code from cached HTML (if you don't have a successful backup)
References[edit | edit source]
- ↑ Manual_talk:Backing_up_a_wiki#Ubuntu_10.10_-_Step_by_Step_Instructions
- ↑ XML dumps are independent of the database structure, and can be imported into future (and even past) versions of MediaWiki.