Join 9,000+ Readers

Restoring and Backing Up WordPress Databases

by Jake Rocheleau

on April 14, 2013

in Wordpress

It will require time and patience to work around your own WordPress backups. And when an accident occurs you will be happy that you took the time for properly managing your data. However the process can be stressful, so you want to ensure that everything is properly saved and ready to go.

wordpress database backups website servers

In this article I want to share a few brief points about restoring your WordPress install. But the whole procedure begins with a regular backup of your database and WordPress files. It is definitely a bit more complicated if you are not familiar with working on a server. But if you managed to install WordPress, I would like to think you could also backup and restore these files.

Manual Backups

The first step is making a catalog all the files you will need. Generally this will include every single file located inside your WordPress installation and all sub-directories. The best way to do this is via FTP using a free solution like FileZilla or Cyberduck.

It is best to generate a brand new folder with the name of your website. So if we were performing a local backup on this site I would create a new folder named “colorburned.com” which contains all the website files. Alternately you may name this folder “public_html” which is standard practice in most Linux server environments.

Now if you want to split everything it might be a good idea to create another folder named “database”. Then put both of these directories inside a new folder with the current date and name of website. Now you have a basic public_html folder will all the website files, plus a database backup stored with the exact date.

Moving the Database

It is important to consider the size of your database before performing a backup. If you have lots of posts or pages and users then your DB size is probably very large, and zipping the contents will result in a much smaller file. The two basic methods are Zip and GZip.

Both forms of compression are extremely efficient and may also be uploaded right back to another web host. Databases are commonly managed using a service known as phpMyAdmin. You can read a bit more on this WP codex page which focuses on databases. The general process would be to select your database and then choose the Export tab found at the very top.

phpmyadmin how to export database content

On the new page select the ‘custom’ radio button and more options will appear. You should notice all the tables are selected by default, but if this is not the case be sure and select everything. In fact the only super important change is to update ‘Compression’ which can be found under ‘Save output to a file’.

phpmyadmin back up connection database compressed

Selecting Zipped or GZipped will not matter too much. The compression size is just about the same, and both filetypes may be re-uploaded to any phpMyAdmin. Down at the very bottom hit the Go button and after a few seconds your download should begin.

Restoring the Database and Files

Now we can revisit the imaginary scenario that we have back up all the files and database content. Let’s assume suddenly your hosting server hard drive crashes and your entire website is down. Or we can pretend you are switching web hosts and need to get everything working again on a brand new server.

First you should edit the wp-config.php file in your backups folder. This contains a very specific database name, username, and user password, which all pertain to your older installation. All of these will be different with a new database and you’ll have to create them inside cPanel. Be sure you create a new database and save the full name into your config file. Additionally create a new user with all privileges added onto this new database, and save that username/combo as well.

Get back into your FTP program of choice and upload all the files back onto this new web server. While the files are transferring you may also log into the new phpMyAdmin and select the newly-created database. Then on the Import tab browse to your zipped/gzipped backup and upload right into the server. It may take a few minutes of processing but everything should work out.

If the zipped/gzipped file is too large it is possible to split the lines yourself. This would take a lot of work, and it is a good idea to limit your database backups to less than 100MB-1GB. This isn’t a solid rule but different web hosts will have different limits on the upload capacity. If you are still running into problems check out this WP codex page related to uploading & restoring any WordPress site.

Related Articles

Final Thoughts

I hope this guide may prove useful to some WordPress developers or webmasters. When you lose unsaved data by accident it has to be the worst feeling. By holding vigilant and keeping local backups every few weeks or months, it will ensure this should not be a problem. There are certainly a lot of different methods for doing WordPress backups. Although this is the most direct solution, you may enjoy the above list of related articles for alternative backup solutions. If you have any further questions or comments on the post feel free to share with us in the discussion area below.

About Jake Rocheleau

Jake is a freelance writer and web developer. He writes articles for numerous blogs on freelancing, Wordpress, CSS3, and jQuery. You can find him all throughout Google and follow his tweets @jakerocheleau. Connect with Jake on Google +