Wordpress Backup and Restore

There are easy ways to install, backup, and restore a WordPress website. But sometimes you just wanna do it the hard way. So here is the quick and dirty on how to perform a full backup of a WordPress website, and then restore it later.

MySql Database Backup

mysqldump --add--drop-table -u [dbusername] [dbname] -p | gzip > mywebsite_20150302.sql.gz  

WordPress backup

tar -czvf mywebsite_20150302.tar.gz mywebsite/  

Create new MySql Database and Restore

mysql -u [adminuser] -p

mysql> CREATE DATABASE dbname;  
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON dbname.* TO "wordpressusername"@"hostname" IDENTIFIED BY "password";  
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

mysql> EXIT  

Then restore

zcat mywebsite_20150302.sql.gz | mysql -u [dbuser] -p [dbname]  

Unzip the Filesystem Backup

tar -zxvf mywebsite_20150302.tar.gz  

Paul Soucy

Read more posts by this author.