Title: Problems replicating WordPress site
Last modified: March 13, 2023

---

# Problems replicating WordPress site

 *  [johnny2r](https://wordpress.org/support/users/johnny2r/)
 * (@johnny2r)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/problems-replicating-wordpress-site/)
 * Without using any plugins etc., I am trying to replicate a WordPress site, which
   I will call, for the sake of argument, ‘www.mysite.com’, at a different subdomain,‘
   staging.mysite.com’. I am doing this via ssh and I have full root access. I have
   taken a fairly basic approach. What I have done is to replace all instances of
   the string ‘www.mysite.com’ in the files in the WordPress directory with ‘staging.
   mysite.com’. Similarly, I’ve done an export (mysqldump) of the database from 
   the live site, replaced all instances of the string ‘www.mysite.com’ with ‘staging.
   mysite.com’ throughout the SQL dump and imported it for the staging site.
 * So, theoretically, at this point it should be identical to the original site 
   but with the new subdomain in place. But it’s not working properly – I’m getting
   some empty links instead of links to pages under the new subdomain and I don’t
   see how this can possibly happen, given what I’ve done. I’ve tried clearing all
   caches, to no avail. Any suggestions as to what I might have overlooked? (I should
   add that all values in wp-config.php have been correctly updated for the new 
   site).
 * I used the same approach on another site and it worked perfectly, so I’m at a
   loss to understand how this could possibly not work, as it’s so fundamental and
   basic.
    -  This topic was modified 3 years, 2 months ago by [johnny2r](https://wordpress.org/support/users/johnny2r/).

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Alan Fuller](https://wordpress.org/support/users/alanfuller/)
 * (@alanfuller)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/problems-replicating-wordpress-site/#post-16555170)
 * > replaced all instances of the string ‘www.mysite.com’ with ‘staging.mysite.
   > com’
 * Dont do this – you may have got lucky but if [http://www.mysite.com](http://www.mysite.com)
   is not EXACTLY the same length as staging.mysite.com then you wil break things
   
   The best way to update the databse data with root / SSH access is to use WP CLI
   and use WP Search-Replace
 * wp search-replace –all-tables –precise “[http://old&#8221](http://old&#8221);“
   [https://new&#8221](https://new&#8221);
 * wp search-replace –all-tables –precise “[http://old&#8221](http://old&#8221);“
   [https://new&#8221](https://new&#8221);
 *  Thread Starter [johnny2r](https://wordpress.org/support/users/johnny2r/)
 * (@johnny2r)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/problems-replicating-wordpress-site/#post-16555516)
 * What do you mean by ‘exactly the same length’? What length are you talking about?
   My understanding is that using `wp search-replace –all-tables –precise` as you
   say will have exactly the same effect as doing it directly on the mysqldump file.
   Is this not the case? I’ll give it a go nonetheless.
 *  [Alan Fuller](https://wordpress.org/support/users/alanfuller/)
 * (@alanfuller)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/problems-replicating-wordpress-site/#post-16556083)
 * Exactly the same length strings.
   So technically WP stores array data using PHP
   serialized data formats which basically is a character count followed by the 
   string. see [https://en.wikipedia.org/wiki/PHP_serialization_format](https://en.wikipedia.org/wiki/PHP_serialization_format)
   Take the object stored as
 * `O:8:"stdClass":2:{s:4:"John";d:3.14;s:4:"Jane";d:2.718;}`
 * and the replace John with Jenny ( different lengths )
 *     ```wp-block-code
       O:8:"stdClass":2:{s:4:"Jenny";d:3.14;s:4:"Jane";d:2.718;}
       ```
   
 * You can see that s:4 is wrong ( it should be s:5 ) so now Jenny would actually
   only be Jenn – now you should have a full understanding why a text replace of
   a string of different lengths will break WP
    -  This reply was modified 3 years, 2 months ago by [Alan Fuller](https://wordpress.org/support/users/alanfuller/).
 *  Thread Starter [johnny2r](https://wordpress.org/support/users/johnny2r/)
 * (@johnny2r)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/problems-replicating-wordpress-site/#post-16558828)
 * OK, thanks, that’s clearer. I don’t think I’m doing it quite right, though. I
   used this:
 * `wp search-replace –all-tables –precise --allow-root "https://www” "https://staging”`
 * and got a message saying Couldn’t find any tables matching: [https://www”](https://www”)
   [https://staging](https://staging). So could you perhaps help me by giving an
   exact command to replace all instances of [http://www.mysite.com](http://www.mysite.com)
   with staging.mysite.com? I assume this applies only to the database?
 * LATER: It’s OK, thanks, I’ve done it: `wp search-replace 'www.mysite.com' 'staging.
   mysite.com' --precise --recurse-objects --all-tables --allow-root`
    -  This reply was modified 3 years, 2 months ago by [johnny2r](https://wordpress.org/support/users/johnny2r/).
 *  [Alan Fuller](https://wordpress.org/support/users/alanfuller/)
 * (@alanfuller)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/problems-replicating-wordpress-site/#post-16558858)
 * [https://developer.wordpress.org/cli/commands/search-replace/#examples](https://developer.wordpress.org/cli/commands/search-replace/#examples)
 *  Thread Starter [johnny2r](https://wordpress.org/support/users/johnny2r/)
 * (@johnny2r)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/problems-replicating-wordpress-site/#post-16558907)
 * Thanks, figured it out (I edited my post).

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Problems replicating WordPress site’ is closed to new replies.

## Tags

 * [replication](https://wordpress.org/support/topic-tag/replication/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 2 participants
 * Last reply from: [johnny2r](https://wordpress.org/support/users/johnny2r/)
 * Last activity: [3 years, 2 months ago](https://wordpress.org/support/topic/problems-replicating-wordpress-site/#post-16558907)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
