Recovering WordPress and Mediawiki

My primary hard drive on mccune.ece.cmu.edu crashed yesterday. It crashed in a pseudo-friendly way, so I didn’t lose any data. Of course, it was all backed up anyways… 😉

However, I opted to reinstall Debian including apache2 and mysql, the infrastructure for WordPress and MediaWiki. Thus, it was time to see how easy it is to restore this stuff.

I first copied all the actual .php files, etc into the directory which Apache makes accessible to the web.

For MediaWiki:


create database DATABASE;
create user USER identified by 'PASSWORD';
grant select,insert,update,delete on DATABASE.* to USER;

mysql -u root -p DATABASE < ~/mediawiki_backup.sql The DATABASE, USER, and PASSWORD go in LocalSettings.php. For WordPress:
create database DATABASE;
create user USER identified by ‘PASSWORD’;
grant all on DATABASE.* to USER;

mysql -u root -p DATABASE < ~/wordpress_backup.sql The DATABASE, USER, and PASSWORD go in wp-config.php. If, upon thinking everything is correct, it says "It doesn't look like you've installed WP yet. Try running install.php." go ahead and click it. You will then need to repopulate the database tables with your .sql file again, because install.php will overwrite them with default values. Those _backup.sql files were created with commands like this one: mysqldump --add-drop-table -u root -p DATABASE > DATABASE_backup.sql

The resulting .sql file contains SQL commands to reinsert everything into the database. The “add-drop-table” tells MySQL to drop destination tables if they already exist. For example, clicking the “install.php” for WordPress created the default, mostly-empty database tables. Those got dropped and replaced by my tables.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s