HOWTO: Debian + Drupal upgrade

I always forget to take notes when I do a Drupal upgrade. This blog entry will be my notes for this upgrade of my home boxes. I will use it in turn to upgrade FOB, and then hopefully use it again when it's time to upgrade again in the future…

I need to upgrade three different Drupal sites hosted at my home from 4.7.4-->4.7.8-->5.3. The middle migration is just because it is unlikely the last one will work unless one rotates through first. Currently, the sites are running 4.7.4 as installed by me. Now Debian has reasonably up-to-date Drupal packages, so I'm moving back to Debian again.

  1. Do some prep work. Identify any themes you are going to upgrade, and make a plan for that; probably the best idea is to get an upgrade patch ready using some test instance. Identify any non-standard modules you're using, and get new versions ready. Identify any module patches you're using, and make sure they're ready to go.

  2. Check for backups. First, back up /etc/drupal. For me, that was easy—I had previously configured everything to run without it.

    Next, move your old stuff out of the way. For me, /usr/share/drupal-4.7.4 contains everything interesting, and /usr/share/drupal-4.7 is a symlink. So removing the symlink is sufficient to mostly protect my stuff.

    Finally, make sure that your SQL database is being backed up. I have an /etc/cron.daily/mysql-backup that dumps the database into a compressed file nightly. Then my normal backup stuff backs up the file. But I am careful about these things, so I used "mysqldump --defaults-file=/etc/mysql/debian.cnf --all-databases > ~/tmp/my.sql" to make a current snapshot. Now, if the upgrade goes horribly wrong, I can get back to where I was.

  3. Log into the sites as admin. Keep a browser open once you've done this. You're going to need it to update the sites' databases later. Also, remember to turn off any custom theme. This is a mighty pain to work around if you forget and the new version breaks on your theming.

  4. Install Drupal. Since I'm using Debian, it's as easy as "apt-get install drupal-4.7". There were two questions asked by the installation, both of which had context-dependent answers. I chose not to auto-configure any web server with this install—my setup is complex, and I'd prefer to do it by hand. I also chose not to use db-common yet. It turns out it's easier to turn it on after things are set up right. Then I put my symlink removed above back, so that my sites would work while I continued to work on stuff. Unfortunately, the Debian upgrade had nuked PHP4, so I was dead in the water until the upgrade completed. Bleah.

  5. Upgrade the "sites" directory. A default site configuration is in /usr/share/drupal-4.7/sites. I saved it aside and copied the old site configuration in. It turns out that the new site stuff just needs a couple of small files, so I created them for each site. Now each site directory contains settings.php, baseurl.php, and dbconfig.php. I generated the dbconfigs manually, as mentioned earlier. Make sure that dbconfig.php has the right group, as it is protected from world access since it contains a cleartext password.

  6. Upgrade the htaccess file. I always forget this step. In /etc/drupal/4.7/htaccess is a file that among other things has rewrite rules that sometimes need changing. But it turns out I'm OK; all of that is handled elsewhere in my Apache config.

  7. Reinstall missing stuff. Themes being transferred go in the themes directory, of course, and modules in the modules directory.

  8. Check the web server stuff. It's worth seeing if anything changed in /etc/drupal/4.7/apache.conf. But it really didn't. So my setup should still be good.

  9. Update the databases. Edit /usr/share/drupal-4.7/update.php to allow access. For each site, hit http://site/update.php and follow the instructions.

  10. Update the configurations. For each site, looks at the module list, and add any modules that seem to have vanished. Then look at the access rights; new things are generally turned off until you turn them on. Finally, check and update paths that might accidentally have had an old directory name hardcoded in them.

  11. Clean up.Remember to remove the old cron jobs, and the old installation symlinks, and move the old /etc directory. Then use apt-get to uninstall any previous Debian-controlled version.

That's about it. I've come close to finishing bart-massey.com, massey-family.org,
and schalit-way.net. Once I'm confident of these, it's time to do this site. Hopefully the notes I've made will help me. Friend of Bart

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

This looks like A LOT of

This looks like A LOT of work. Is Drupal so fragile?

It's a lot of work

I wouldn't say fragile. But the upgrade process is not as automated as it should be.

Part of the problem is that the theme support keeps changing with each new major release. A lot. Which means that if you've been using a custom theme, as a couple of my sites have, it's a lot of manual work to bring your theme up to date.

These days, modules can upgrade themselves automatically, and the modules I use are pulled right off the Drupal website. Nonetheless, module upgrades are not done automatically—I spend a lot of time trying to figure out which modules need to be installed in the new version, grabbing and installing them.

The good news is that major version upgrades like this only happen about once a year or so. The minor version upgrades tend to be pretty seamless now; especially so now that Debian's Drupal packages are up to date. This is what a distro is suppposed to do for you—Debian's Drupal packagers were screwing up, but that seems to be fixed.

The scary part is that Drupal is the simplest full-featured CMS to install and upgrade that I know of. Friend of Bart