A common and good practice is to build your website in a “staging” location. This allows you to get everything customized the way you need before “going live” with your website.  This is especially helpful if you’re replacing an old website, and you don’t want any downtime. You can completely build your new website in the staging location, and when you’re ready, move that to your actual “live” website.

But actually handling that migration from the “staging” site to the “live” site is a complex thing to do. Some webhosts, like Flywheel, give you the tools to do a 1-click migration from your staging site to your live site.

But most web hosts do not have an option like this yet.

There are a few WordPress plugins out there that aim to make migration easier. For reference here are a couple of those plugins:

Migration options if you’re struggling

While the above plugins are great and typically work well, we’ve also heard from quite a few customers who struggle to use these migration plugins successfully, as they can be complex. So if that’s you, we’d like to give you a few options:

  1. Use a staging service like BlogVault. This is undoubtedly the easiest option, as it’s a one-click operation.
  2. Follow our step-by-step guide using WP Migrate DB to do it yourself (below).
  3. Our team is available for hire if you’d like us to handle it for you. Contact us.

1. Using a Staging Service

Like I mentioned, handling staging and migration is not a simple thing. If this is something you’ve been struggling with for a while and just want to get it done with no more headaches, I would highly recommend taking a look at BlogVault’s staging service.

With it, you can clone your entire site with 1 click, instantly creating an exact replica staging site on BlogVault’s servers. Once you’re sure your staging site is good to go, you can push the entire staging site back to your live site with, again, a single click.

This is truly the headache-free option, and having used it myself for some projects, I have to say that it is pretty impressive. But like most things that get rid of headaches, there’s an added cost, starting at $89 per year. So you’ll have to decide whether that cost is worth the time you’re saving. It’s also worth factoring in the fact that BlogVault can also act as a backup for your site, and they also have a malware protection system if you use their PLUS plan.

While it’s not for everyone’s budget, I just wanted to make sure you were aware of that option before we dive into the steps to do it all yourself manually.

2. Do-It-Yourself Migration

The very first thing to do before migrating is to back everything up. This way, if anything goes wrong during the migration, you won’t lose any of your hard work.

There are two extremely important things that need to be backed-up and then moved properly when migrating from a staging site to a live site:

  • The site’s files
  • The site’s database

What you need before starting:

  • FTP access from your webhost, and an FTP program like Filezilla
  • Access to your database through something like PHPMyAdmin, which is typically found in your web-hosting account

Step 1. Backing up the files

With WordPress, all of your unique files are stored in the “wp-content” directory. Using your FTP program, log in using the information for FTP provided to you by your webhost.

Once you are logged in, browse to the “root” directory of your live site’s WordPress. This is the directory which contains the “wp-content”, “wp-admin”, and “wp-includes” directories, as well as a few other files created by WordPress. Typically this is found in the “public_html” directory.

Then, download your entire wp-content directory to your local hard-drive to back it up. This can take a some time if you have uploaded large files, or if your internet connection is slower. While that is downloading, you can go and make a backup of your database.

Note that you must backup both the staging wp-content directory and the live wp-content directory to make sure you have no data loss. So repeat these backing-up instructions for your staging site as well.

Step 2. Backing up the database

Anything that isn’t a file, like text you’ve saved in a post or text area, is saved to the “database”. This is the second part that needs to be backed up and moved. Typically your webhost will give you access to your database using something like PHPMyAdmin. If your hosting account has cPanel, it may even give you the option to download the database directly.

Now, you’ll need to download a backup of both your live site’s database, and your staging site’s database, to ensure you have a full backup and won’t lose any of your data.

In PHPMyAdmin (or if you’re using a different program like Sequel Pro), locate the database for your live site. Then, select all of the tables and use the menu options to export them.

Repeat this for your staging site as well to back it up.

Step 3. Migrating the files

Once you have completed the backup of the “wp-content” directory, it’s time to move it. If you haven’t completed all of the backup steps above, make sure you do those first. Otherwise you could have major data loss that is not able to be fixed.

Browse to your live site’s root directory again (the one that contains the “wp-content”, “wp-admin”, and “wp-includes” directories), and replace the entire live site’s wp-content directory with your staging site’s wp-content directory, which you’ve downloaded at the second part of Step 1 (above). You’ll want to be very careful here to make sure you are moving from the staging site to the live site, and not the other way around.

You’ll do this in your FTP program again by dragging and dropping the staging site’s wp-content directory into the root directory of the live site.

Step 4. Migrating the Database

One of the main problems that needs to be solved is properly replacing your staging domain name wth your live domain name everywhere it exists in your database. Typically this could exist in several hundred places. For example, if you uploaded a photo, it will be linked in the HTML using the staging domain. So the link to the photo might be “www.staging.mywebsite.com/wp-content/uploads/photo.jpg”. But after you migrate, you need it to be “www.mywebsite.com/wp-content/uploads/photo.jpg”.

Obviously going through and replacing each of those manually could take hours, if not days, and you’re likely to miss one or two, which can be very frustrating. But the free version of the WP Migrate DB plugin does all of that for you flawlessly. You simply use its “Find and Replace” functionality to replace any instances of your staging domain with your live domain. It is extremely smart in the ways that it does finding and replacing, and finds things that most other migration plugins miss.

Once you’ve completed the find and replace, to replace your staging domain with your live domain, download the database it gives you.

Then using your PHPMyAdmin, SequelPro, or some other way you are able to access your database, replace the tables on your live database with the tables you downloaded here from WP Migrate DB.

And that’s it!

Migrating a staging website to a live website is definitely a complex thing that requires a lot of carefulness and attention to detail, as well as a commitment to properly backing everything up. It also requires a pretty clear understanding of database tables and FTP (File Transfer Protocol). But with a commitment to those things, you can make it happen.

If you’d rather hire someone to handle all of that for you, reach out to us and we can make it happen for you.

11 thoughts on “How to migrate your WordPress’s staging website to your live site

  1. My staging site is installed in the main root of my database, along with my “public_html” folder which contains my actual site. I deleted all the contents of my public_html folder, and then transferred all my staging site files into that folder. I then wiped my original sites database and imported my staging site database. Now, when I go to my main site, I can’t log into my dashboard, and the link for the site is still showing up as “https://staging.xxxxx.com/staging/”, and I’m only able to log into my staging site dashboard now. Do you have any advice that you could offer?

    • Hey Mike,

      If you wiped the entire database, as opposed to just the tables within that database, you might need to change the reference to the database in your wp-config.php file in the site root.

  2. When you say to replace the wp-content directory with the new one, do i only replace THAT specific directory named wp-content? Just need clarification. I do not replace the current wp-admin, or wp-includes, or any of the other files? Except the wp-config file to point it to the new database, correct? I do this, and replace the config file, but get an error.

    • Hey Deeva,

      I’m guessing you are talking about step 3 above which says “replace the entire live site’s wp-content directory with your staging site’s wp-content directory”.

      It sounds like you’ve done it correctly. I would need to know the error you are getting to know what might have gone wrong. Send that error over and I’ll see if it helps to shed light on the issue.

  3. Ok so I followed all the steps above and it hasn’t really worked out. Now when you type my live site address eg: http://www.mydomain.com into a browser, it redirects to the staging site eg: staging.mydomain.com I also can only log in to my staging site and not my main site. Any idea what I’ve done wrong?

    • Hey Brett. There’s a number of things that could cause this, but the most likely one is that you might have accidentally changed the WordPress URL in the WordPress settings on your live site, to be the URL for your staging site. To fix that, you would need to log into the database directly using something like PHPMyAdmin, which is usually available at most webhosts.

      Once logged in with PHPMyAdmin, look for the table called “wp_options”. In that table, locate the column called “option_name” and search for the rows called “siteurl” and “home”. For those rows, make sure the value is set to your primary domain, and not your staging site. That would fix it, if the URL was set to your staging site.

      That being said, directly editing the values in the tables is not something I typically recommend unless you are confident in your database management skills. If you aren’t I would recommend hiring a professional to do that for you for the least amount of downtime and headaches.

    • It sounds like it might be possible that your web hosting server wasn’t powerful enough to handle the exporting without crashing. You’ll want to check with your webhost on why that 500 error happened. They should have an error log which would indicate the reason.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.