How to do a full WordPress backup and restore

WordPress is modular but yet very coherent in nature and doing a full backup is not difficult when you know what that you need to backup.

WordPress site consists of several components:

  1. WordPress code (which you can always get from WordPress.org - or you can use Fantastico/CPanel WP installation)
  2. wp-config.php (this file holds your database connection information, it is automatically created if you use Fantastico)
  3. .htaccess (in most cases you can regenerate it from WordPress admin)
  4. wp-content folder (contains your images, attachments, themes and plugins)
  5. Database (contains WordPress settings and posts)

Basically since you can always get WordPress code you just need to backup remaining four things.

You can even live without wp-config.php if you have the database backup, as you can always make new database and create new wp-config.php.

Theoretically you could live without wp-content backup too, as you can install the plugins and theme again and re-upload your photos if you still have them. So that means that your database is the most important part of your WordPress installation and we will start with backing it up first.

Backup

You can setup regular WordPress database backups using WP-DBManager but if you want to do a quick backup, move the site, or install a local copy I recommend using phpMyAdmin interface to your database and doing 'Export'.

Most hosting solutions will have access to phpMyAdmin and all you have to do is select your database and go to Export tab.

Second step is to backup your wp-content folder and that is done through a FTP program. Most important folders inside it are uploads (your images and file attachments), themes and plugins. Copy the whole folder to a safe place.

Next is copying wp-config.php and .htaccess, which are just two configuration files.

This concludes your backup.

Restoring the backup

Here are some scenarios of doing a restore.

Database

  • Import is typically performed through phpMyAdmin. You may need to drop (remove) old tables before you do that if you did not checkĀ  "Add DROP TABLE / VIEW / PROCEDURE / FUNCTION" when you did database export.
  • If you lost your original database, you will need to create a new one and perform the import. Note that you may need to change wp-config.php file with your new database name, user and password
  • If you are making a copy of the site to another site you need to do one more thing. There are two records in wp_options table called siteurl and home (this one is usually on the second page when you browse the table in phpMyAdmin). These two carry your website URL and tell WordPress what site it is installed on. You need to edit these two fields and enter the new site URL here

wp options 600x246 How to do a full WordPress backup and restore

wp-content

This is pretty straightforward, just copy your wp-content to your site. All plugin and theme settings are saved in your database.

wp-config.php

This involves copying the file, if necessary. Be careful when copying wp-config.php over an existing file as the existing file could hold updated information. So I recommend you backup the existing file just in case.

.htaccess

Normally when you restore everything, you would go to WordPress->Settings->Permalinks and click Save. This will recreate your permalink settings and create .htaccess file.

Your site should work normally now. If it is still not the case you might want to compare the two files (backup file and created file) to see if there are any differences.

See also:


Posted in: WordPress
TAGS:, , , , , , , , , , , , , , ,
leave a comment.

8 Comments

  1. monica dart monicadartphotography.com
    May 1st, 2010

    hi -- i'm hoping you can please help. i had wordpress 9.1.1 with my logo, theme, layout etc. which forms part of my website. I updated to 9.2.2 and the whole look of my blog completely changed. my logo and theme disappeared and all the photo's i've uploaded appear squashed and warped . is there any way to go back to 9.1.1 or restore what seems to have completely changed? ie get my wallpaper, font, photo's back to how they previously were? thanks,
    monica

  2. php html php-html.net
    Mar 11th, 2010

    [...]A complete guide describing how to do full WordPress backup and restore.[...]

  3. Shakhawat kavkisfile.com
    Mar 7th, 2010

    How can I change wordpress table prefix without disabling any plugins?

  4. Asheer febno.com
    Mar 1st, 2010

    Hello, Very useful tutorial for the moving wordpress site to another host. Thank u so mcuh..............

  5. Laurie theadventurouswriter.com
    Feb 25th, 2010

    Hi Vlad,

    Thanks so much for the Amazing Grace theme! I've been loving it for 3 months now, but today had a problem.

    Why are these sidebars showing up in the left and bottom of my most recent post? They never showed up before, and I can't get rid of them!

    http://theadventurouswriter.com/quipstipsspiritualseekers/

    Thanks,
    Laurie

    • Brian santaigochiletravel.com
      Feb 26th, 2010

      Hi Laurie,

      Sorry to say, this isn't the place for this question, I'll answer it but if you need anymore help then we'll meet in the forum next time.

      What you are seeing on the screen is Google adsense and it is the probably because of a plugin you have installed or a script you have inserted.

      WB

  6. Omer Greenwald webtechwise.com
    Feb 17th, 2010

    Hi Vladimir, I think every blogger should create a duplicate of their live blog locally to create a test enviroment.
    This way they can test plugins and function without having to be worried about live effects.
    Check out my post about this http://www.webtechwise.com/how-to-backup-your-wordpress-blog-and-install-it-locally-using-xampp/

    Thanks

  7. Rarst rarst.net
    Feb 17th, 2010

    I use Cobian Backup to make automatic backups from FTP. However it became really slow and unreliable when there are thousand+ of folders and files.

    Good way is to use file manager in cpanel (or whatever host uses) to pack everything into single archive and download it (just need to be careful to not create/leave it in public folder).

    I pitched around idea for WP plugin that will zip and serve such file automatically but so far no takers. :) Might get to coding it myself when my skills up to it.

Have your say

Your email is never published nor shared. Required fields are marked *

*
*

Subscribe without commenting

About Vladimir

vladimir prelovac Hi! My name is Vladimir Prelovac. I am a computer engineer by profession and an adventurer by state of mind.

"I would love to change the world, I just don't have the source code yet."

Books by Vladimir

WordPress Plugin Devleopment Book WordPress Plugin Development: Beginner's Guide

Published by Packt Publishing, available online through Amazon. Click the image for more information.

Consulting Services

Professional WordPress Services, including custom developed plugins and themes

Expert on-site WordPress SEO consulting and an 'out-of-the-box thinking' approach to problems