Help:Backup database

From GRWiktionaryHelp

(Redirected from Backup Database)

MediaWiki Handbook: Contents | How To Use Help | Other help Software help for MediaWikiReaders, Editors, Admins e0 +/-


This process is the same for upgrading mediawiki, except, when you upgrade your mediawiki, you don't have to restore your database unless there was an error, and the exporting step serves as a backup step.

When upgrading in the same version tree (1.4.x to 1.4.y, etc.) just copying the files over the current installation should work. But backup before you do this!

Contents

Overview

The purpose of this document

The instructions here are to help you move a MediaWiki database from one web host to another. You do this when you change hosting providers... etc. You will also have to transfer your domain name, but since everyone changing hosts has to do that usually your new host will have a slick FAQ on how to do that.

The sticking points in a move

When you move your wiki, there are three things to be pay attention to. (and one thing to do)

  1. Your data
  2. Your settings
  3. Your images
  4. Your domain name

The instructions provided here deal with moving the first three of these things.

General step-by-step process

Some notes based on a exchange of email on Mediawiki-l (between Manuel Schmidt and Brion Vibber, 24 Apr 2004). Not done or tested. Please improve!

1. Dump the SQL database from oldsite.

2. Keep copy of LocalSettings.php.

3. Create new (empty and default) instance of Mediawiki.

Or delay this step after step 4 and fill the database name and other settings same to those when you were installing your old one.

4. create database on the new machine, Load SQL dump into new database.

5. Move images directory from oldsite to newsite.

Customize LocalSettings.php and database to match each other and new server.

"You might have to manually set up MySQL user access permissions again, depending on the setup"

A step-by-step example

This is an example to migrate mediawiki from machine A to B running windows, considering the possible difference between mediawiki versions on two machines:

1. dump database named 'mywikidb' on A to a single sql file

C:\easyphp\mysql\bin>mysqldump.exe -u root -p --single-transaction mywikidb > backup.sql
Enter password: *******

EDIT: Don't forget to add --default-character-set=latin1 (or whatever yours is, latin1 is the default) if you have non-ASCII characters in there for mySQL 4.1.2 or later. See http://mail.wikipedia.org/pipermail/mediawiki-l/2004-November/002245.html for more information. You can also use phpMyAdmin if you don't have console access.

2. copy backup.sql from A to B . The sql file may be very large but can be easily shrinked using any compress tool

3. create a database with the same name 'mywikidb' on B

 $ mysql -u root -p
  Enter root password: ****
  mysql> create database mywikidb;
  mysql> use mywikidb;

4. import 'mywikidb' from A on B by executing the dumped sql script, make sure it is located in the current directory.

  mysql> source backup.sql;

5. install mediawiki as usual, but change the database's name from the default 'wikidb' to 'mywikidb' Mediawiki will detect there is a pre-existing database and try to upgrade it when necessary. EDIT: this is a lie. The install script simply overwrites the existing database and you are left in the mire. Thanks, Wiki.

Also, the language setting MUST be the same as the original one!!

6. copy the LocalSettings.php to config's parent directory. Change settings to the same ones as the LocalSetting.php from machine A.

EDIT: You can copy the old LocalSettings.php file, but I had to change the following:

  • "$IP =" line, as the wiki was on a different drive
  • "$wgLogo =" line, and copy the logo file to the new server
  • "$wgDBpassword =" because I got this wrong when setting up the database

In general, just carefuly check through the local settings file.

7. move images from A to B. Make sure the permission is set right for Linux.

8. Done!

Notes on rebuilding link tables

EDIT: Hopefully this shouldn't be necessary.

Rebuilding the link tables may take a long time, particularly if you've installed the English database, which is kinda big. (Note also that you can skip the old table if you wish.) See Database layout on what rebuilding.php is good for.

Note that if you want to create a public mirror of Wikipedia, this probably isn't the best way to go about it. If you do set up a mirror this way, please tweak the code to note that you're looking at a mirror and include links back to the main site.

check user permissions

You might have to manually set up MySQL user access permissions again, depending on the setup

how?

Log into the "mysql" database as root:

shellprompt# mysql -u root -p mysql
     {enter password}
mysql> SELECT * FROM user;

If you don't see the user you want (e.g., "wikidbuser") and/or it doesn't have the correct permissions, you can remedy this with the following command:

mysql> GRANT ALL PRIVILEGES ON wikidbname.* TO wikidbuser@localhost
    ->     IDENTIFIED BY 'some_pass' WITH GRANT OPTION;

This should get the user database back on track.

  • I think wikidbuser doesn't need ALL PRIVILEGES, just SELECT,INSERT,DELETE,UPDATE. Thigs like ALTER and CREATE/DROP are not needed, aren't they?
  • After reading everything on this site it seems clear that there is no reliable way to restore the actual pages on the wiki; one can certainly restore the database, but so what? What kind of support is this? Nobody is going to use your software unless it can be reliably upgraded.
The database IS the actual pages.
MediaWiki Handbook: Contents | Other help


Reading: Go | Search | URL | Namespace | Page name | Section | Link | Backlinks | Piped link | Interwiki link | Redirect | Variable | Category | Special page
Tracking changes: Recent | (enhanced) | Related | Watching pages | Page history | Diff | User contributions | Edit summary | Minor edit |
Logging in and preferences: Logging in | Preferences | User style
Editing: Overview | Wikitext | New page | List | Images/files | Image page | Special characters | Formula | Table | EasyTimeline | Template | Renaming / Moving a page | Editing shortcuts | Talk page | Testing | Export |

Wiki Projects: Wikibooks | Wikicommons | Wikipedia | Wikiquote | Wikisource | Wiktionary |