Complete backup and restore WordPress

Complete backup and restore WordPress

Backup and restore WordPress can be done easily via several already-made plugins. However, I want to do it the easy way without installing any extra stuffs to my web.

Backup and restore WordPress

I’m a software engineer and I love to do things my ways; so, backup and restore WordPress is one of my tasks that I can do to enjoy typing in the terminal.

1. Backup WordPress

I don’t use share hosting for my web, always serve from servers I have permissions and can manage, mostly through SSH connection.

Following is what I do to backup WordPress.

$ mysqldump -h SERVER -u USER -p DB_NAME > SITE_DATE_backup.sql
$ tar -zcvf SITE_wp.tar.gz PATH/TO/PUBLIC 

That’s all for backup.

Note: if you’re using some custom themes, make sure to check if they provide backup and restore for their themes’ configs.

2. Restore WordPress

Nothing fancy here, just upload the backup files to target deployment servers, and

$ mysql -u USER -p DB_NAME < BACKUP.sql

Extract the compressed WordPress directory, config the web server to point to root directory.

If using nginx, it’s better to change owner for all files.

$ chown -R www-data:www-data PATH/TO/WORDPRESS

Note: if using custom themes, make sure to check if there is provision for backup and restore for theme’s config.


For me, it is very enjoyable to backup and restore WordPress like this. I also write my own tools to automate these tasks for clients when necessary. Plugins might work better, but it is overkilled!