I’ve been migrating domains from an old server to a new one that we’ve just acquired. Some were really straightforward standalone CMS setups, so a
tar xcf and an
scp followed by a
mysqldump and a
mysql < database.sql sufficed.
But there were ones that had multiple webapps running off the same domain. I had a Piwik installation on http://example.com/analytics, then a random dokuwiki setup running at http://example.com/wiki. While it’s all too easy to simply create a subfolder and dump the files in, a setup like this makes incremental migration very difficult. When you cut over the DNS records for the domain from an old IP to a new IP, everything needs to work at the first try.
A better way is to have each webapp run in a seperate subdomain. Instead of http://example.com/analytics, set it up at http://analytics.example.com/. Instead of http://example.com/wiki, set it up as http://wiki.example.com/. Sure it’s a few extra steps when setting up, but decoupling your webapps is good practice.
When it’s time to move one of the webapps to its own server, or migrate your domain incrementally, you can simply copy over all the files for that one webapp, repopulate the database tables, do a test run using your HOSTS file, then flip the switch at your DNS server when you’re ready. The big win? Everything else on http://example.com/ continues to hum along swimmingly.