How to do a full WordPress backup and restore

Update: I recommend using ManageWP to easily backup/restore/migrate your WordPress sites.

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-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.

Note: Our ManageWP.com service allows automatic backups and also cloning of WordPress sites.


More like this:


Posted in: WordPress
TAGS:, , , , , , , , , , , , , , ,
Both comments and trackbacks are currently closed.

18 Comments

  1. Feb 3rd, 2013

    Fantastic! This is exactly what I needed. Now I have c complete clarity about what I have to do. I prefer to avoid using plugins as much as I can. Now I know exactly how proper backup is done.

  2. Jan 21st, 2013

    I have also made an article called : Automatic WordPress Backups with Dropbox

    http://www.squidoo.com/automatic-wordpress-backups-with-dropbox-free

    And I also talk in that article about how to backup your free WordPress.com blog .

    hope that helps someone !

    Cheers !

  3. Apr 19th, 2012

    I really need help, I want to back up all the content of my site because its always get hacked... what is the best plugins to back up all the content of my site.. There's a lot of plugins but I have already doubt on it.. Get hacked always hope you could help me..thanks

  4. Apr 2nd, 2012

    Thanks for sharing this information. I will surely try it. Please keep posting.

  5. Feb 14th, 2012

    Hi Vladimir , great post . There are thousands of post about this subject i found none of them helpful...thanks for the beautiful tut ...cheers have a great weekend.

    • Feb 14th, 2012

      Thanks, I appreciate it!

  6. Jul 14th, 2011

    Nice tutorial about backing up the wordpress installation and database effectively.

  7. John Maverick
    Nov 2nd, 2010

    I am using a very nice plugin from http://www.xcloner.com to backup and restore my WordPress website, works like a charm....

  8. Oct 27th, 2010

    okay, so does that mean all my pages and posts that i have on my dashboard will get saved on the database? or how do i save all that content? reply to my email pleaseeeeeeee.

  9. 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

  10. Mar 11th, 2010

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

  11. Mar 7th, 2010

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

  12. Mar 1st, 2010

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

  13. 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

    • 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

  14. 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

  15. 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.

  • ManageWP