0

I'm trying to clone a wordpress blog that i have on a internet web server on my local machine. I performed the following steps.

  1. Backed up and Restored Mysql DB on localbox
  2. Copied all filesystem files on local box
  3. Changed wp-config.php to reflect local box settings
  4. Changed wp_options table. Set wp_options to point to localhost address where option_name is 'siteurl', 'home'.

It seems to be working, however all the content that I uploaded (like images) is yet pointing to http://www.olddomain.com/wp-content/uploads/2013/05/some_image.jpg. Now I notice that within the wp_posts, all posts have this href hardcoded to old domain.

Questions:

  1. Can we fix wp_posts so that there is no connection to old domain blog? I was thinking of writing a script that will replace all instances of old domain with localhost address. Is there a cleaner way of doing this? This way the clone would be complete.
  2. Is this a correct backup? Am i missing something? I know there might be other ways of doing this (import/export tool) however, I am more comfortable doing a db & filesystem sync every time I want to backup my data.
0
  1. you can use this tool http://interconnectit.com/products/search-and-replace-for-wordpress-databases/ to replaces the urls. The advantage over SQL replace is that the tool know how to handle serialized info in the DB.

  2. Being easy to sync is problematic requirement with the way you are trying to do things. If you need that, then you should simply change your localhosts file to point olddomain.com to 127.0.0.1 and then you will not need to do any alterations to code or data. This is the right way to go especially if you have a dedicated testing machine.

  • I used the 2nd option of changing the localhosts file. – nev.m Nov 21 '13 at 8:09
0

I usually do an export to xml and do a find an replace all in that xml for all external links and change them to a local structure. After thats all replaced, import that xml to your local installation. Then all links should be in order.

Having a "clean" local installation that way is more "safe" then messing around in the database and having the risk of forgetting to change something.

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.