WordPress Workbench - Find replace for DB on cloning

When I clone the Wordpress from boilerplate.originaldomain.com to a new top level domain newdomain.com, many records in the Wordpress database still include https://boilerplate.originaldomain.com, or https:\/\/http://boilerplate.originaldomain.com\ etc… then I will need to fix the db through sql find and replace. Can you include a find / replace in the cloning function to replace any instances of boilerplate.originaldomain.com with the newdomain.com in the sql automatically? This can also be offered as an option, if other users prefer not to find/replace automatically.

I am trying to replace my previous backup / restore solution with WPworkbench, specially using CLI commands for automation. My previous solution does the automatic find/replace and saves me from manual work.

2 Likes

Hello, Kamyar!

Thanks for the heads up!

Yes, I could, but could you explain more about which database fields and in which tables still have the old domain name? And, we do update the wp_options table, and its siteurl, and home—it isn’t a problem for you, right?

Also, do we really need an option, or can we just always perform the replace?

I have a set of preconfigured plugins in the Wordpress that I use as boilerplate. Many of them save the domain name in one way or another. Another place I spotted them are in the custom fields attached to posts and pages, the domain names are not replaced. Another is my theme which saves some of my custom CSS codes in the database. The URL of background images stays as the old domain etc… that is why in general it is helpful to have a complete find and replace, no matter which table.

My previous solutions (Akeeba Backup) does this but asks for confirmation before applying the find/replace which I think is not needed or might make WPworkbench too complicated. I can’t recall clear reasons why when someone clones WP from domain1.com to domain2.com would need to keep some URLs in the database as domain1.com, but there might be cases I am not aware of. So maybe it can be an optional find/replace? or no?

By the way, the other solution also replaces instances of /home/boilerplate.domain.com/ with the new /home/newdomain/ in the whole database.

Is there a case when such replacement wouldn’t be needed? I’m thinking of making it automatic since it’s highly unlikely that the old domain name needs to be preserved upon cloning?

Is the domain home directory also stored in the database?

Is there a case when such replacement wouldn’t be needed? I’m thinking of making it automatic since it’s highly unlikely that the old domain name needs to be preserved upon cloning?

I can’t think of any general case that replacement won’t be needed.

For the home directory, I only found one instance related to the backup plugin that was saved in the database.

I didn’t realize the WP Workbench could let me move my wordpress instance from /wp/ to the root… I’ll need to check it out…

That’s also entirely soluble with a simple rewrite rule in your webserver configuration.

Yes, it can do that as well. Just make sure you have the latest version installed!