How do I clone my Wordpress site to a development site?

This is easy do do if you know your way around FTP and phpMyAdmin.  If this starts to go over your head, don't worry, we can do this for you for a fee of $29.95.

First of all, you need to make sure you have a dev site set up on your VPS. Log in to https://dashboard.brownrice.com, and navigate to VPSs > Manage > Websites.  Scroll down to the section "Websites hosted on this VPS".  If you see one called "http://dev.yourwebsite.com", you already have a dev site. If you don't see one, just click the "Add a new website or subdomain" button to create it.

If you already have a dev site, you'll need to FTP in and make sure the docs.dev folder is empty before proceeding.

See this FAQ for instructions on creating FTP or SSH users: https://support.brownrice.com/content/2/202/en/how-do-i-administer-my-smartvps.html

Copying the files

The first step is to get your website files copied over. You'll need to copy the entire contents of /home/domains/yourdomain.com/docs/ to /home/domains/yourdomain.com/docs.dev/. If you're using FTP, you'll do this by downloading the contents of docs to your computer, and re-uploading them into docs.dev. If you're a command line (SSH) user, you can simply run this command:

cd /home/domains/yourdomain.com/docs; cp * ../docs.dev or rsync -avW /home/domains/yourdomain.com/docs/ /home/domains/yourwebsite.com/docs.dev/

Copying the database

Again, refer to this FAQ for instructions on logging in to your phpMyAdmin: https://support.brownrice.com/content/2/202/en/how-do-i-administer-my-smartvps.html

Next, refer to this FAQ for instructions on creating a new user / database pair on your SmartVPS: https://support.brownrice.com/content/2/263/en/how-do-i-set-up-a-database-on-my-smart-vps.html

Once that's done, you'll navigate to the existing live database, and click the Export button to download an .sql file. Then, you'll navigate to the new dev database you just created, click the Import button, and import the .sql file into the new database.

For SSH users, you can do this quickly and easily like so:

mysql -e "CREATE DATABASE mywordpresssite_dev"
mysql -e "GRANT ALL PRIVILEGES ON mywordpresssite_dev.* TO mywordpresssite_dev@localhost IDENTIFIED BY 'ENTER-A-NEW-PASSWORD-HERE'"
mysql mywordpresssite_dev < /home/db_dumps/LIVE_DATABASE_NAME.sql

We create a backup of your site files and databases every morning, so a very recent copy of the live database will already exist in /home/db_dumps. If you need a fresher copy, just mysqldump databasename > databasename.sql to grab it.

You'll need to know your Wordpress database name, user name and password of course. This info can be found in the wp-config.php file you copied over in the first step.

Updating the permalinks

  • Login to Wordpess: http://dev.yourwebsite.com/wp-login.php
  • Click -> Settings -> General.
  • Change both the Wordpress address and Site Address to read: https://dev.yourwebsite.com.
  • Click Save Changes.
  • Click Permalinks.
  • Click Save Changes (yes, you don't actually change anything on the Permalinks page, you only click Save Changes.)
  • Done.
Tags: clone, copy, dev, development

You cannot comment on this entry