{ Prep DB Dump Before Going Live }

I wrote this code for WordPress, but I suppose it’s applicable to any CMS.

You develop on a dev server, it’s possible your CMS will have the dev server’s domain name in the db a couple of times. It can be tricky to go through the db and change every occurrence of http://dev03.zone5dev.net to something else. Especially if you have posts with dozens of links to uploaded content…

So here’s a script to do it for you. This assumes that during the process of making a site live, you do a full db dump (export from phpMyAdmin) and you have that file.

php clean_wp.php your_db_dump.sql http://devxx.zone5dev.com http://www.livesite.com

This is going to replace all of the dev sites with the live sites. It’s also going to parse the devxx part out of the dev site and look for /home/zone5dev/public_html/devxx and completely remove those.

It produces a copy of your sql file, which you should be able to import with phpMyAdmin on the live site.

Adapt as necessary.

clean_wp.php

Leave a Reply

Your email address will not be published. Required fields are marked *