There are several reasons why you might want to copy your website,
- you want to make a “sandbox” copy to experiment on, without affecting the public-facing production site
- you want to change hosting companies to get a better deal, faster performance or more functionality
- having a complete copy of your website is a great insurance policy should something happen to your host and your site is lost.
If your site uses WordPress then just copying the files in your account is not sufficient. Since WordPress stores almost all of your site’s content in a MySQL database, you have to copy that too.
Manual WordPress Backup and Migration
Just copying your Posts and Pages
WordPress includes Export/Import tools that create and use an XML file to make a copy of your site. The drawback of this method is that it does not copy your themes, plugins, or preserve your menus and widget settings. But it is a quick method to grab and move your WordPress website contents.
First you export an XML file from the original site. The tool downloads this to your computer. Then using the import tool you upload that same file. During the import process you can choose to have the new site find and copy all the images you used on your posts and pages and add them to the Media Library of the new site.
These tools are in the Tools section of the WordPress dashboard
Making a complete copy of your website including the themes, images, and plugins and all your configuration settings
1. First install a new copy of WordPress in the location you want for your new site.
Many website hosting companies offer a “one-click” install of WordPress that creates all the files and the database you need.
2. Copy the files, images, themes, and plugins you’ve added to your existing website.
All of the image files you’ve inserted into your posts and pages are stored in a directory in the file system. Also, the themes and plugins you’ve added are also stored in the file system. So the next thing to do is make a copy of the /wp-content/ subdirectory in your WordPress website directory. The wp-content directory includes the /themes/, /plugins/, and /uploads/ directories, and the /uploads/ directory is where all your images are stored. You have to have file manager access to your hosting account either through the hosting company control panel via a browser, or via ftp access using an ftp application like Filezilla.
Make a copy of the directory and download it to your computer
3. After you make a copy of the /wp-content/ directory you replace the wp-content directory in new location with the copy from your old site. This will get you all your images, themes, and plugins, but not your posts, pages, menus, user accounts, or any of your configurations and settings. Those are all stored in your database.
4. Make a copy of your database
Most of your text and configurations are stored in the WordPress MySQL database, so next we need to copy the database.
There are several methods that will do this.
1. You can export the database using your host’s control panel phpMyAdmin utility
2. There are several backup plugins that will make a copy of your database. BackWPup (free) and BackupBuddy (not free) are a good for this.
You will download the exported .sql file to your computer
4. Replace the new website database with your exported database
Just as you used phpMyAdmin utility to export your existing database, you use the same utility to empty the default tables in the new database and import your .sql file to replace the default data from the new WordPress installation.
But before you can import the data from your old site you need to get rid of the existing data. This is called “dropping” the tables. You select all the tables then select Drop from the menu.
After you Drop the tables you have an empty database ready to import your old website data. Use the Import link to begin the process and upload the .sql file you saved to your computer. Once this is uploaded you’re almost done.
5. Edit the location of your new website in the database
Since you now have an exact copy of the old site there are a couple of problems. WordPress still thinks it is located at the original URL. You have to select the “Options” table in the new database and edit records #1 and #37 which tell WordPress where it lives.
You will see the old URL in those fields. Replace with the new URL and save. At this point you should be able to go to the new URL and see your old website with everything in place. But there may still be one more problem. If you have internal links in your posts or pages linking to somewhere within the website those will still point to the original URLs. You have to install a Search and Replace plugin to find all the instances of your old URL in the database and replace those with the new URL.
After you have finished this go to your Settings>Permalinks in your dashboard and just Save. This refreshes the permalink settings for the new URL.
Moving your site using a Migration Tool plugin
As you’ve seen above, copying and migrating manually is possible, but is detailed and exacting. There are multiple steps and making a mistake anywhere along the way will cause the process to fail. But there are a couple of plugins that automate the process.
BackupBuddy costs $80 and Duplicator is free. For copying and migrating your WordPress website they work almost exactly the same. They create a “package” which includes all your files from your wp-content directory AND all the WordPress files too. They also create an installer.php file you use to migrate the site.
Here’s how the process works.
- Install the plugin of your choice.
- Run the plugin to create a package and installer file and download those to your computer.
- Create a MySQL database for the new location (this is the most technical part of the process, you need an empty database and you need to know the database name, database user name, and password).
- Upload the package and installer files to the new location.
- Run the installer.php program at the new URL. It will ask you to verify the new URL and what the new database credentials are (from #3 above).
- The installer program then unpacks all the WordPress files and all your data, imports all the content, themes, plugins, configuration and settings into the wp-content folder and the database, and then changes all the URLs from the old site to the new location!
- It’s still a good idea to go into the new site and update the Permalink settings. But other than that, you’re done.
The first time you do this, give yourself an hour. But after that it usually takes about 15 minutes. I do this frequently and in most cases prefer using the Duplicator plugin.