Restoring a Wordpress site from a manual backup
I have been storing backups of database dumps and the served HTML/PHP files of my Wordpress blog for years now, but never tried to re-deploy the website from these backups. Today I’ve finally spent a few hours to figure this out. These are my step-by-step notes so it’ll be faster next time.
- Start an AMI of the bitnami LAMP stack on EC2
- Put it in a security group that allows HTTP(S) traffic
- Write down the “application password” from the System log. It looks something like:
Setting Bitnami application password to 'i1y0QrIDMBNH'
- upload (scp) DB.sql and wordpress HTML/PHP zip to the server’s home directory
- SSH over there:
ssh -i ~/AWS/mykey.pem bitnami@52.59.227.153
mysql -u root -p
- Use the application password to login
- Set up the database:
CREATE DATABASE DB1738312; CREATE USER 'U1738312'@'localhost'; GRANT ALL PRIVILEGES ON *.* To 'U1738312'@'localhost' IDENTIFIED BY 't42KJ423; # Use your real wordpress site's user, DB, and password
- Then source the exported SQL script to fill the database:
mysql -u U1738312 -p DB1738312 < DB1738312_2018-07-03.sql
unzip my-wordpress-backup.zip -d htdocs/
(have index.php in htdocs/, not a subdir, though)
chmod -R ugo+rw htdocs/
- For some reason, the .htaccess was not readable or writable. You need writable for the permalinks to work
- Log back in to MySQL and update siteurl & home:
UPDATE wp_options SET option_value='http://52.59.227.153' WHERE option_name='siteurl';
UPDATE wp_options SET option_value='http://52.59.227.153' WHERE option_name='home';
- Browse to http://52.59.227.153/ and verify all’s well
- If it isn’t, login to http://52.59.227.153/wp-admin/