WikiServer - How to actually move a MediaWiki to a new machine

From The TinkerNet Wiki
Jump to navigation Jump to search

BACKING UP

From: The MediaWiki Manual

Example of the command to run on the Linux/UNIX shell:

mysqldump -h hostname -u userid -p --default-character-set=whatever dbname > backup.sql

Substituting hostname, userid, whatever, and dbname as appropriate. All four may be found in your LocalSettings.php (LSP) file. hostname may be found under $wgDBserver; by default it is localhost. 'userid may be found under $wgDBuser, 'whatever may be found under $wgDBTableOptions, where it is listed after DEFAULT CHARSET=. If whatever is not specified mysqldump will likely use the default of utf8, or if using an older version of MySQL, latin1. While dbname 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).

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

SO:

mysqldump -h localhost -u root -p --default-character-set=binary tinker_wiki | gzip > backup.sql.gz

RESTORING

From: The MediaWiki Manual

Re-create the database, user and permissions

From the MySQL prompt as MySQL user root you can:

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

SO:

CREATE DATABASE tinker_wiki;
CREATE USER root IDENTIFIED BY '******';
USE tinker_wiki;
GRANT SELECT, UPDATE, INSERT, DELETE, ALTER, CREATE, INDEX, USAGE ON tinker_wiki.* TO root;

Import the database backup

mysqladmin -u root -p drop tinker_wiki

mysqladmin -u root -p create tinker_wiki

mysql -u root -p tinker_wiki < backup.sql

  • NOTE: unzip it first! ***
     

and afterwards if you've upgraded to a newer version of MediaWiki you'll need to:

php wikifolder/maintenance/update.php

  • Most people name their wikifolder simply "w", making this pathname
  • something like "htdocs/w/maintenance/update.php"

SO:

php /var/www/html/wiki/maintenance/update.php

Now for the files...

On the old machine:

tar zcvhf wikidata.tgz /var/www/html/wiki

On the new machine:

tar zxvhf wikidata.tgz

(Seems to recreate the entire path under the location the command was run...  hhhmmm... Should look into that instead of just moving it aftwerwards...)