Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


14,517 Points

Copy Wordpress Blog to Test Sub-domain

I currently have a blog on a sub-domain (blog.fraplantools.com) and I want to make several enhancements so I've created a test sub-domain (test.fraplantools.com). What's the easiest way to copy all of my code from blog.fra to test.fra so that I can test a new theme and rearrange the content.

Currently, I've copied the entire code for Wordpress from the blog folder to test folder, but that didn't work. Right now, I've copied just the themes and the uploads folder and I'm still googling what else I need to copy.

Any help would be greatly appreciated!

5 Answers

BackWPup is a great free plugin that will help you back your site up. Then you'll need to do move both the database and the files, probably all of the files. I've run into trouble testing features on sites where I wasn't running the full gamut of plugins I was using on the production site, and didn't know about a lot of kinks some of them threw (particularly any caching and/or CDN).

For help moving the database, there's a great Wordpress Codex article here.

This should be easier, but it's not. There are several steps involved.

Stephen's right. You need to move both the database and the files, separately. There's another new, fantastic plugin called WP Migrate DB Pro that will copy all your database info from one location to another.

So I recommend that you install WP Migrate DB on your site then:

  1. create a new database (usually through phpMyAdmin) for the new location,
  2. copy the files over,
  3. use WP Migrate DB to copy the database info over,
  4. verify new the wp-config.php file has the right database information. It should work then.

Copying it back to the live location is the same thing in reverse.

I hope this works for you. If not, let me know because I'm in the middle of this myself and want to get the documentation/instructions correct and clear for future use.

14,517 Points

Julie Kuehl thanks for the information. I currently have backupwordpress installed and I have over 15 backups on the server, so right now I'm transferring that backup to the new environment to attempt a restore. From the research I've done on this plug-in apparently it's that easy (which is never the case). If it fails I will take your approach and let you know.

14,517 Points

So no luck on my end. Hopefully Zac Gordon will have some insight on how to do this. I made a Wordpress backup and just imported the backup on my UAT (Test) Server and just adjusted the wp-config file and that didn't even work. Nor any restore methods of the backups via plugins.

I can't believe Wordpress is truly this difficult in duplicate your blog on a test environment to work on changes, etc.

It is a little nuts. But if you're having troubles, you are not alone.

Another great resource, with a price, is BackupBuddy http://ithemes.com/purchase/backupbuddy/

Guido Grulke
Guido Grulke
20,948 Points

as Julie said there are a couple of things to do, in addition to restore the files in the new directory. I prefer to create a database dump from the phpmyadmin frontend, create a new db and then import the dump into the new database. Be aware to change the url Settings in the options Table, because your site url is no longer blog.fraplantools.com, so you has to change it to test.fraplantools.com. If your files are in place and the wp-config.php is updated with the right information, this should work.

If not, please post an error message or some more information what is not working.

If you like, we can do it together.

I know there's a lot of information out on the web about this process, but here's the one I found most helpful: http://www.byobwebsite.com/seminars/wordpress/create-a-development-copy-of-your-live-wordpress-site-on-a-subdomain/

I hope you've gotten yourself set up by now.

Gautam Thapar
Gautam Thapar
5,265 Points

When I moved one of my website to another domain, I did the following (the easiest I did) -

  1. Installed a fresh copy of Wordpress on new domain. Checked if it was working fine.

  2. Imported all my content using the Wordpress import/export tool. Checked whether the content appeared correctly.

  3. Copied the respective theme to the new install. If you also want plugins then you can add them manually.

That's it! Hope I didn't miss something.

With big data we do require importing the database. In that case you can copy the files and import the database. Make sure wp-config.php is correctly configured.

When using database restore or moving database, you will need to manually change the website domain in your database (2 instances). I think it is under wp-options. Search your current domain under wp-options and change it to the new domain.