How to Clone a WordPress Site for Testing Without Touching the Live One
You want to try a new theme, test a plugin update, or rebuild a page, but doing it on the live site risks breaking something visitors can see. The safe answer is to clone a WordPress site into a separate copy where you can break things freely. A clone is a full copy of your files and database running at a different address, so your live site stays untouched while you experiment. This guide walks through both ways to do it: with a plugin and by hand on your VPS.
What a Clone Actually Copies (and What It Does Not)
A proper clone copies two things: every file under your WordPress install, and the full database. The files include themes, plugins, uploads, and wp-config.php. The database holds your posts, pages, settings, and plugin data. If either half is missing or out of date, the clone will look wrong or refuse to load.
A clone does not copy your domain name, your SSL certificate, or your email setup. It also does not copy server cron jobs that send email or sync files. And a clone is not a backup. A backup is a file you store somewhere safe and restore only when something breaks. A clone is a running copy you keep testing on, and it drifts away from the live site the moment you change anything in either place.
Pick a Place for the Clone
Before you copy anything, decide where the clone will live. The three common choices are a subdomain, a subdirectory, or a local install on your own computer. To clone a WordPress site to a subdomain like staging.yoursite.com, create the subdomain first and point its document root at an empty folder. A subdomain gets its own server block, and you can lock it down with a password. If you already run a WordPress staging site on a VPS subdomain, you can reuse that setup and skip the server work.
A subdirectory like yoursite.com/staging works, but it shares the live site’s server block and rewrite rules, which can cause odd redirect problems. A local install is fine for quick theme checks, but it cannot show you how the site behaves on your real server. For a test that you can trust, a subdomain on the same VPS wins.
Whatever you pick, block the clone from search engines. Add a password with basic auth in Nginx, and tick the “discourage search engines” box in Settings, Reading on the clone.
How to Clone a WordPress Site with a Plugin
The fastest way to copy a site is a WordPress migration plugin. Duplicator, All-in-One WP Migration, and WP Migrate all do the same basic job: they pack your files and database into one archive, then unpack it at the new address and rewrite the URLs for you.
- Install the plugin on the live site and create a package or export file.
- Download the archive and the installer file it gives you.
- Create an empty database and database user on your VPS for the clone.
- Upload the archive and installer to the clone’s document root.
- Open the installer in your browser and enter the new database details and address.
- Delete the installer files when the process finishes, then log in to the clone and check the front page.
Free versions often cap the size of the site you can move, and some cap the upload size on the restore side. If your media library is large, check the limit before you start, and check official pricing if you need the paid version. If you want help picking one, this comparison of WP Migrate vs All-in-One WP Migration vs Duplicator breaks down the differences. Also note that a plugin clone copies the database exactly as it is, so a slow live site usually produces a slow clone too.
Clone a WordPress Site by Hand with Files and Database
Doing it by hand takes longer, but it works on sites of any size and teaches you what each piece does. It is the better choice for a large site, or when a plugin refuses to run because of a server limit.
First, copy the files with rsync, leaving out the cache directory:
rsync -a --exclude=wp-content/cache/ /var/www/live/ /var/www/staging/
Next, dump the live database and import it into the clone’s database:
mysqldump -u liveuser -p livedb > /tmp/live.sql
mysql -u staginguser -p stagingdb < /tmp/live.sql
If you back up databases by hand already, this part will feel familiar, and the same mysqldump and cron backup routine you use for nightly backups gives you a ready-made dump to start from. Then copy wp-config.php into the clone’s folder and change the database name, user, password, and table prefix if it differs. Finally, point a server block at the clone’s folder, add the subdomain DNS record, and reload Nginx.
The manual route has one catch: the database still contains the live address everywhere. You fix that in the next step, and you must fix it before you open the clone in a browser, or WordPress will redirect you straight back to the live site.
Fix the URLs and Settings After the Copy
After the copy, search and replace the old address with the new one across the whole database. Use WP-CLI or a search-replace tool that handles serialized data, because a plain SQL replace corrupts serialized arrays and breaks widgets and theme settings.
wp search-replace 'https://yoursite.com' 'https://staging.yoursite.com' --all-tables --precise
Then check the clone’s settings: Settings, General should show the staging address, and any plugin that points at an outside service should be switched to test mode or turned off. A clone that still sends real order emails can cause real confusion. This is the same reason you should test restores before you trust them, and a backup restore test on a separate copy follows the same idea: never trust a copy you have not actually opened and clicked through.
Also clear every cache on the clone: the object cache, any page cache files, and the CDN cache if one is in front of it. Stale cache is the most common reason a fresh clone shows old content.
What Usually Goes Wrong
Cloning is simple in theory, but a few problems show up again and again. The first is the white screen after import, which usually means the clone runs a different PHP version than the live site, or a plugin needs a PHP extension that is missing on the staging server block. Compare the PHP versions first; it takes a minute and saves an hour of guessing.
The second is mixed content warnings, where the clone loads over HTTPS but pulls images or scripts over HTTP. That happens when the search-replace missed some URLs, often in theme options stored in the database. Run the search-replace again with the plain http version of the old address as well.
The third is a clone that keeps redirecting to the live site. That means wp-config.php still holds the old address in WP_HOME or WP_SITEURL constants, or the search-replace did not run. Check the constants first, then the wp_options table.
The fourth is a clone that is too slow to test anything on. If the live site has a bloated database with years of post revisions and expired transients, the clone inherits all of it. Clean the live database first, then clone again.
And the last is the human one: forgetting which tab is the clone and which is live. Give the clone a visible marker, such as a different admin color scheme or a small banner plugin, so you never edit the live site by mistake. If you are moving a site between hosts rather than cloning it, the steps overlap a lot with migrating WordPress from shared hosting to a VPS, where the same search-replace and DNS steps apply.
FAQ
How often should I refresh the clone?
Refresh it before any important test, and at least once a month if you test often. A clone that is weeks behind the live site can hide real problems, because the plugin versions and content no longer match what visitors see.
Can I push changes from the clone back to the live site?
Not with a single button in most setups. Theme and plugin file changes can be copied back, but database changes are hard to merge because posts and orders kept changing on the live site while you tested. Treat the clone as a place to prove a change works, then repeat the change on the live site by hand.
Does a clone slow down the live site?
A clone on the same VPS shares CPU, RAM, and disk with the live site, so a heavy test can slow the live site for a few minutes. Run heavy tests at quiet hours, and delete clones you no longer need instead of letting them pile up.