Manual:Restoring a wiki from backup/ja

例え復元する必要がないウィキであっても、定期的にウィキのバックアップを実施すべきです. バックアップは安心を与えてくれます. ところが、バックアップは復元できないと役に立ちません. バックアップを復元すれば後の面倒な作業をしなくて済むのです. 以下はその方法についての説明です.

バージョンとアップグレード
このページにある説明は概ねどのバージョンのMediawikiにも通用する内容となっているでしょう. データベースはより新しいバージョンのMediawikiに復元できますが、更新スクリプトを忘れず実行するようにしてください. 新しいバージョンのデータベースを古いバージョンのソフトウェアに復元する操作はサポートしていません.

ファイル転送
ウィキを置いているサーバへ直接アクセスできない場合、ファイルを転送する方法を選ぶ必要があります.


 * SCPまたはWinSCPを使って安全にコピーする
 * SSHファイル転送プロトコル（SFTP）
 * FTPクライアントを使う
 * ホスティング会社がウェブブラウザを使ったファイル管理インタフェースを提供しているかもしれません. 提供会社から提供されている情報を確認してください.
 * この他の手段は、これらの手法を記したファイル転送プロトコル一覧に記載されています.

概要

 * 1) データベース、ユーザ、アクセス権限の再構築
 * 2) データベースのバックアップのインポート
 * 3) MediaWikiファイルのインポート
 * 4) 設定ファイルの確認
 * 5) テスト

データベース、ユーザ、アクセス権限の再構築
On the server on which you are restoring MediaWiki, ensure you have


 * 1) a correctly-working instance of MySQL
 * 2) a MySQL user with appropriate permissions, if you can't use MySQL user root

If you are restoring from backup due to database corruption, consider reinstalling MySQL! Once MySQL is working properly, create a new MySQL database and grant your user account permissions on the database. SELECT, INSERT, UPDATE, DELETE and DROP permissions should suffice. You may need to consult the MySQL documentation, your hosting provider's control panel documentation, or the documentation of any other utilities you are using for information on how to do this. From the MySQL prompt as MySQL user root you can:

CREATE DATABASE wikidb; CREATE USER wikidb_user IDENTIFIED BY &#39;wikidb_userpassword&#39;; USE wikidb; GRANT SELECT, UPDATE, INSERT, DELETE, ALTER, CREATE, INDEX, USAGE ON wikidb.* TO wikidb_user;

データベースのバックアップのインポート
Next, import your database backup. This will create the tables in the database and populate them with data. Importing takes a variable amount of time, depending upon the number of pages, users, edits, etc. in your wiki.

を使ってコマンドラインから実行する
If a database exists and you want to entirely replace it from the backup. To destroy the database: mysqladmin -u wikidb_user -p drop wikidb Substituting as appropriate for  and. The  parameter will prompt you for the password.

Then to create a new database: mysqladmin -u wikidb_user -p create wikidb

For example after backing up with mysqldump: mysqldump --default-character-set=binary --user=wikidb_user --password=wikidb_userpassword wikidb > dump_of_wikidb.sql Make sure to specify the correct character set or the restore may fail, check  to find out which character set it is.
 * 1) Don't do this now: This is how you might have created a backup earlier.
 * 1) The wikidatabase wikidb from which you backed up may have a different name
 * 2) than the wikidatabase wikidb you've created above. Of course wikidb_user and
 * 3) wikidb_userpassword may be different as well.

To import  from the command line you simply do: mysql -u wikidb_user -p wikidb < dump_of_wikidb.sql and afterwards if required do: php wikifolder/maintenance/update.php
 * 1) Most people name their wikifolder simply "w", making this pathname
 * 2) something like "htdocs/w/maintenance/update.php"

See also Executing SQL Statements from a Text File

With the browser for phpMyAdmin
Open the browser to your phpMyAdmin, login, choose the wiki database. (Check LocalSettings.php if you're not sure). Select Structure, localhost, Your_Table. Select CheckAll. From the drop down select Drop, then Ok to wipe the old table. Click on Import, select Browse, pick your uncompressed plain text SQL file and import it. Press Go.

Remember to also restore file system components of the wiki that might be required, eg. images, logo, and extensions, (see above under mysql).

Depending on timeout settings and the size of the SQL file, it may take multiple attempts to import everything. Failure to complete the import may leave the database in an inconsistent state, e.g. with missing revisions.

外部リンク

 * Siteground: MySQL Export: How to backup a MySQL database using phpMyAdmin also describes restoring from backup
 * Restoring the Database
 * phpMyAdmin

XMLダンプからの復元
Main article: 

To import an XML dump into a wiki, use the command-line tool importDump.php. Do: php wikifolder/maintenance/importDump.php --dbpass wikidb_userpassword --quiet --wiki wikidb path-to-dumpfile/dumpfile.xml php wikifolder/maintenance/rebuildrecentchanges.php Substitute,   and   as appropriate.

Afterwards use ImportImages.php to import the images: php wikifolder/maintenance/importImages.php wikifolder_backup/images

MediaWikiファイルのインポート
Next, restore your backup of the MediaWiki filesystem: this is the final "large" step in the restore process.


 * If you followed the backup manual instructions, and backed up the entire directory, this will include the images and extensions directories, plus custom skins, etc. and the configuration file.
 * If you backed up only portions of the directory, e.g. images, extensions, etc. then you will need to first upload/copy a fresh install of the MediaWiki files, then transfer the backed-up directories and files into the correct locations in the new filesystem.

To wipe and restore the wiki file system
Remember to also restore the file system components of the wiki that might be required, eg. images, logo, and extensions. Especially to edit  to check everything is correct. A sequence of Linux commands to wipe and restore the wiki file system could look like this: wget http://download.wikimedia.org/mediawiki/ /mediawiki-.tar.gz tar -xvzf mediawiki-.tar.gz rm mediawiki-.tar.gz rm -fR wikifolder/ mv mediawiki- wikifolder rm -fR wikifolder/extensions/ cp -R wikifolder_backup/extensions wikifolder/extensions Open the wiki from the browser and click on the Set up the wiki first link. See Manual:Config script for details. If needed, you can run the command-line installer. After this is done edit  to suit the fresh install, restoring lines for extensions, etc. Restore from backup any other files, such as a custom logo and favicon to the correct paths.

If you've not installed as a root Linux/Unix user and the images and thumbnails don't work, you'll need to fix the owner or permissions recursively on the folder that has the uploaded images, usually in wikifolder/images.

設定ファイルの確認
The final task involves verification of, and possibly modifying, the  file.
 * If you are restoring onto the same server from which you backed up, you probably need not change anything.
 * If you are restoring onto a new server (i.e., if you are moving or duplicating the MediaWiki), certain entries will almost undoubtedly require changing, and you may need to change the database connection information as well.

Check the following configuration options: You might also need to check the paths to diff3, ImageMagick, etc.

テスト
At this point, attempt to access the wiki on the new server and use it. Log in as a sysop and a regular user and check that viewing, creating and editing pages and uploading files still works. You will need to fix any problems reported either by PHP or MediaWiki itself.

よくある問題
After your move you might see PHP warnings stating that certain files could not be accessed. This is most likely caused by T37472: The column md_deps in the module-deps table contains absolute file paths, which are used to locate the images and LESS files that CSS depends on. These paths will break when the wiki is e.g. moved to another folder or to another server.

Until this bug is solved, you can use this workaround to manually fix wrong entries in the module_deps table: This can be used to update wrong path segments and to fix the error.

関連項目

 * （バックアップに失敗した場合）
 * Script: Fullsiterestore
 * （バックアップに失敗した場合）
 * Script: Fullsiterestore
 * Script: Fullsiterestore
 * Script: Fullsiterestore

外部リンク

 * Detailed instructions on 'Migrating to a new server'