Manual:Backing up a wiki/ja

ウィキ内のデータのバックアップを定期的に作成することは重要です. このページでは、典型的な MediaWiki ウィキのバックアップ手順の概要を説明します.

概要
MediaWiki は、重要なデータを 2 箇所に保持しています:
 * データベース : ページとその内容、利用者とその個人設定、メタデータ、検索のインデックス情報など.
 * ファイルシステム : ソフトウェア構成ファイル、カスタム外装、拡張機能、画像 (削除されたものを含む) など.

バックアップを作る前に、ウィキを読み取り専用にする（$wgReadOnly 参照）ことを検討してください. これによって出来上がったバックアップが自己矛盾の無いものとなります (一部の拡張機能は読み取り専用にしてもデータを書き込むかもしれません).

ファイル転送
サーバーからファイルを転送するための方法を選択する必要があります:


 * 非公開ではないデータであれば単にpublish on archive.orgまたはwebサーバーの ディレクトリの中に入っています.
 * SCP (または WinSCP)、SFTP/FTP などの転送プロトコルが使用できます.
 * ホスティング会社がwebブラウザー上で動作するファイルマネージャーを提供しているかも知れません.

データベース
殆どの重要なデータは簡単にバックアップできるデータベース内に保存されています. 既定のMySQLバックエンドを使用している場合、このデータベースはスクリプトファイルとしてダンプすることができます. このスクリプトファイルを使ってゼロからデータベースを再構築できます.

Automysqlbackup
See the package on Debian:

$ apt show automysqlbackup [...] Description: automysqlbackup creates backup every day, week and month for all of your MySQL database, to a configured folder. There's nothing to do but to install this package, and you'll rest assured that you have a way to go back in the history of your database. [...]

パッケージをインストール:


 * 1) apt install automysqlbackup

All your databases will be saved in /var/lib/automysqlbackup/:

$ find /var/lib/automysqlbackup/ /var/lib/automysqlbackup/ /var/lib/automysqlbackup/weekly /var/lib/automysqlbackup/weekly/my_wiki /var/lib/automysqlbackup/weekly/my_wiki/my_wiki_week.18.2016-05-07_15h32m.sql.gz /var/lib/automysqlbackup/monthly /var/lib/automysqlbackup/daily /var/lib/automysqlbackup/daily/my_wiki

Manual backup:


 * 1) automysqlbackup

Restore a database:

For other distributions, see on Sourceforge.

コマンドラインでmysqldumpを実行する
最も簡便なのは、MySQLに標準で付属するMySQL ダンプツール （mysqldump）を用いることである. これは、バックアップ対象のデータベース名やテーブル名を指定してダンプファイルを作成することができるコマンドラインアプリケーションである.

First insert the following line into LocalSettings.php $wgReadOnly = 'Dumping Database, Access will be restored shortly'; this can be removed as soon as the dump is completed.

Linux/UNIX シェル上で実行するコマンドの例: mysqldump -h hostname -u userid -p --default-character-set=whatever dbname > backup.sql Substituting,  ,  , and   as appropriate. All four may be found in your LocalSettings.php (LSP) file. may be found under $wgDBserver; by default it is localhost. may be found under $wgDBuser,  may be found under $wgDBTableOptions, where it is listed after. If  is not specified mysqldump will likely use the default of utf8, or if using an older version of MySQL, latin1. While  may be found under $wgDBname. After running this line from the command line mysqldump will prompt for the server password (which may be found under Manual:$wgDBpassword in LSP).

コマンドライン パラメーターの完全な一覧については mysqldump を参照してください.

The output from mysqldump can instead be piped to gzip, for a smaller output file, as follows mysqldump -h hostname -u userid -p 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 -p --xml dbname > backup.xml and to compress the file with a pipe to gzip mysqldump -h hostname -u userid -p --xml dbname | gzip > backup.xml.gz

Remember to also backup the file system components of the wiki that might be required, e.g., images, logo, and extensions.

cronでのmysqldumpの実行
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.

A sample command that you may run from a crontab may look like this:  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  lowers the priority of the process.

Use valid values for,  , and. 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.

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

エスケープしないと、以下のエラーになります: /bin/sh: -c: line 0: unexpected EOF while looking for matching `'' /bin/sh: -c: line 1: syntax error: unexpected end of file

テーブル
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からUTF-8への変換
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
You can use the  tool to back up a MediaWiki PostgreSQL database. For example: pg_dump mywiki > mywikidump.sql will dump the  database to mywikidump.sql.

ダンプをリストアするには以下の通り: 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

phpMyAdmin
Turn your wiki to read only by adding  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.

Remove  from LocalSettings.php

Remember to also backup the file system components of the wiki that might be required, eg. images, logo, and extensions.

外部リンク

 * For a tutorial, see Siteground: MySQL Export: How to backup a MySQL database using phpMyAdmin''
 * Backing up the Database

HeidiSQL
HeidiSQL is similar to phpMyAdmin, but without any restrictions of phpMyAdmin's free version. HeidiSQL requires a direct database connection, where some hosts may only offer web interfaces (phpMyAdmin) to firewalled databases.

ファイルシステム
データベースに保存するよりもファイルシステムに保存した方が適切であるような要素についてはファイルシステムの中に保存されます. 例えばサイトの設定ファイル（ 、 (最終的に 1.23 で除去されました)）や画像ファイル（削除された画像、サムネイル、数式やSVGファイルも含む）、スキンのカスタマイズ設定、Extensionファイルなどが該当思案す.

これらのファイルをバックアップするのに最適な方法は、.tarのようなアーカイブファイル（必要が有れば圧縮して）に纏めることです. WindowsであればWinZipや7-Zipといったアプリケーションが使用できます.

Linuxの場合でWikiが /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.

ウィキのコンテンツのバックアップ (XML ダンプ)
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).

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, located in the   directory of your MediaWiki installation. See Manual:dumpBackup.php for more details.

You can also create an XML dump for a specific set of pages online, using Special:Export, although attempting to dump large quantities of pages through this interface will usually time out.

To import an XML dump into a wiki, use the command-line tool. 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  and , you can use MWDumper, which is faster, but requires a Java runtime environment.

''詳細情報は Manual:XML ダンプの取り込み を参照してください. ''

サーバーにシェルでアクセスできない場合
If you have no shell access, then use the WikiTeam Python script dumpgenerator.py from a DOS, Unix or Linux command-line. Requires Python v2 (v3 doesn't yet work).

To get an XML, with edit histories, dump and a dump of all images plus their descriptions. Without extensions and LocalSettings.php configs.

Full instructions are at the WikiTeam tutorial.

Data dumps も参照してください.

スクリプト

 * Unofficial backup script by User:Duesentrieb.


 * 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)


 * Fullsitebackup


 * 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:


 * 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.

関連項目

 * Manual:Restoring a wiki from backup
 * Manual:ウィキの移動
 * Manual:アップグレード
 * Manual:Restoring wiki code from cached HTML (if you don't have a successful backup)