1

What is the best way to duplicate an entire Wordpress site, including database, themes, plugins and all associated settings to another URL for development purposes, and then redeploying it back to the main site?

The site in question is a large Wordpress install — Wordpress 3.5 to be specific — with thousands of posts and a large audience.

I have seen various plugins which purport to do this, but what is the best way to duplicate for development and then, in a month or two, redeploy back? I am committed to keeping the development database up to date manually with the existing database once the split occurs – I don't envision using the same database on two installs or whatever.

Thanks.

  • Are you allowed to create a subdomain on your host? – eyoung100 May 30 '14 at 19:38
  • Yes, our host is Amazon AWS. – Edmund Heaphy May 30 '14 at 20:23
  • Sorry it took so long....There's a lot of info below. If you have any questions please ask. – eyoung100 May 30 '14 at 21:34
0

The environment I work in has a development, staging and production server. We set up a Git repository and don't track the wp-config file. We always copy the DB down, production -> staging -> development, and not the other way around.

Only thing you have to do when you pull commits after your create plugins, update plugins or modify URL stuff is activate, deactivate/reactivate and flush the permalinks.

| improve this answer | |
0

The method I use on Live domains is:

  1. Create a subdomain using your host's control panel named developer/test etc.
    Ex: developer.example.com
  2. Login to your site via FTP, and copy your entire root to your machine, i.e if your root is public_html, highlight it in your FTP software, and download to desktop.
  3. In the copy on your desktop, rename wp-config.php to wp-config.old
  4. Copy public_html from the location you saved it to in Step 2 to the new directory that should have been created at the end of Step 1.
  5. Choose a database Option from below. Use your preferred method and your hosting tools to copy the data. The question you asked is answered with option 1.
  6. Upload the wp-config.old file you modified in step 5 to the sub domain. Rename it to wp-config.php
  7. Type the subdomain in your browser. You should see a copy of your production site, but we aren't done yet.
  8. Login as your admin user. Modify the admin password in the developer instance only. This helps you remember which site you're working on.
  9. Activate a robots.txt File to keep Search engines from indexing the subdomain. See Block a Subdomain from Search Engines

Database Option 1

Make a copy of your Database from your host control panel, i.e highlight the current database, and find the button that says Copy Database. When it asks for a new name, name it the original name and add _dev to the end. In wp-config.old find the dabase connection info, and change the table information to match your new _dev database. Copy the wp_ tables into the *_dev database. See this answer over at StackOverFlow - Production DB to Dev DB. If you want to merge changes when finished, use the Link for Option 1 to copy *_dev into Production

Database Option 2

If your host doesn't allow multiple databases, in wp-config.old find the line #table_prefix. Change the table prefix to something like devwp_. Copy the wp_* tables into the new wpdev_* tables. See this answer over at StackOverFlow - Production Tables to Dev Tables. If you want to merge changes when finished, use the Link for Option 2 to copy wpdev_* into Production

| improve this answer | |
  • That is absolutely fantastic. Thank you so much. However, I haven't grasped the final part, wherein the database table is copied back into the original database. Won't there be duplicate posts, then? – Edmund Heaphy May 30 '14 at 22:13
  • Actually, I have just thought of what I think would work, if I plan to update the second site as the main site is being updated: it would simply be a matter of copying the public_html from the subdomain over to the main domain, while leaving the same database and deleting the subdomain install, right? – Edmund Heaphy May 30 '14 at 22:16
  • Use the link in either option to go back and forth, from dev to production and vice versa. To control the amount of duplication you are going to have to run a compare. Export the data before a merge into Excel etc from both databases and then do an insert 1 by one. Please note you can't use the WordPress UI for that. Add a plugin like this one to Production while performing INSERT's and UPDATE's – eyoung100 May 30 '14 at 22:22
  • You never want to delete the subdomain. That's why Step 9 exists. You'll always have "a rolling development environment" as long as you follow this method. If your development cycles are extended periods, i.e. fix something then wait a year then its easier to empty the subdomain and repeat these steps a year later. I think that's where you were headed. – eyoung100 May 30 '14 at 22:27
  • @EdmundHeaphy Welcome to Stack Exchange BTW – eyoung100 May 30 '14 at 22:47
0

I use https://wordpress.org/plugins/backwpup/ to backup (Files and Database) everything. I upload it to the new host. I update the sql tables in phpMyAdmin.

Then if I want to keep the same domain name then I just point the dns or change the a records.

IF I want a new domain. I use https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ to search and replace with OR without regex if you want (You can use for more than just domain name without knowing any SQL for phpMyAdmin.) and replace the Old domain name with the NEW domain name.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.