I’ll soon be going through the almost-always-painful process of switching hosts on a site I’m working on. I’ve become much better at planning for these over the years, but the complexity of sites I build has added more variables to the mix that I need to account for which probably negates any advantage I thought I had.
There is still an uncomfortably large amount of guesswork and finger-crossing leading up to the switch. Inevitably, some setting or other doesn’t get transferred which makes for a day or two of debugging after the fact.
Here’s my working checklist of things that need to happen. Any you’d add?
- Transfer files.
- All the .html, .php, .jpg, etc. files sitting on the old server need to move to the new server. In the past I’d have used an FTP program to take care of the job, but thanks to rsync I can much more quickly mirror the two servers. At the moment I transfer the data from the old server to my local hard drive temporarily, and then re-upload to the new server. I suspect I can skip the middle step of my local system and do a direct transfer, but it never hurts to have the data in more than one spot anyway.
- Transfer databases.
- All MySQL databases need to move as well; though I’m generally not a big fan of it, PHPMyAdmin is a bit easier to wrangle than the command line (sometimes), and has a one-click import/export function.
- Change absolute paths.
- Some of my custom PHP relies on absolute server paths for
include files and the likefile output. As much as possible I’ve been declaring the path as a constant in global file, so it makes for a somewhat easier migration; except that the path to the global file itself is usually absolute, so unfortunately that does mean a bunch of find and replacing.
- Verify permissions.
- I’ve been using PHP’s ability to write files to the server in a function that grabs EXIF metadata from images and caches that in static text files. Problem being, PHP’s file management honours file permissions, and I’ve yet to de-tangle which combination of permission/ownership I need to assign the script and write directory in order to securely write these files; to actually make it work the way I’d expect, I’ve simply assigned 777 to the directory and treat the cached data as disposable. There must be a better way, but I haven’t found it. The upshot for the migration is namely that I need to ensure these permissions remain unchanged. That’s the other advantage to using rsync over FTP, it should do the work for me.
- Verify passwords.
- I’m hoping the directories I’ve password-protected using
.htpasswdfiles are using relative paths. But in case not, I’ll need to check if the directories that need to be protected are such.
Luckily I haven’t installed any PHP modules or done any extensive customization of Apache, so assuming the new host has a similar setup, that shouldn’t become a problem.
And I have a static IP on the new server, which allows me to test ahead of time, instead of waiting for DNS to propagate before I go into mad panic mode to fix the things that get busted from the switch.
The main question mark for me is mail; assuming I set up the user accounts ahead of time, the transfer shouldn’t interrupt regular mail delivery (aside from the switch in server settings). But I’m not nearly well-versed enough in mail software to know what’ll happen for sure until after I throw the switch.
Again, any glaring omissions would be more than welcomed. I’m hoping I’ve accounted for all I need to, but general advice is always appreciated.