Mediawiki backup

From Ever changing code
Jump to navigation Jump to search

Finally after multiple times I have backed up this and other mediawikis I am going to stream line this process. Any deviration I will record here to work out the best way of doing so. Maybe even the outcome will be a simple script.

More to come....

Recreate wiki database

Create a new MySQL database and grant your user account permissions on the database. SELECT, INSERT, UPDATE and DELETE permissions should suffice.

mysql -u root -ppassword
CREATE DATABASE wikidb ;
CREATE USER wikiuser;
USE wikidb;
GRANT SELECT ON wikidb.* TO wikiuser;
GRANT UPDATE ON wikidb.* TO wikiuser;
GRANT INSERT ON wikidb.* TO wikiuser;
GRANT DELETE ON wikidb.* TO wikiuser;

If a database exists and you want to entirely replace it from the backup. To destroy the database, the -p parameter will prompt you for the password:

mysqladmin -u [userid] -p drop [wikidbname]

Then to create a new database:

mysqladmin -u [userid] -p create [wikidbname]

To import dbdump.sql from the command line do:

sudo mysql -u [userid] -ppassword [databasename] < dbdump.sql

References