2 min read

Disaster recovery Drupal style

My website stands on Drupal, fantastic CMS. Sure it might seem like a little bit of overkill (with all the features and featurettes) for what it is now. But one day it will be grand and powerful and I want to be prepared.

I crashed it today around 1:30am.

You see, I can never get enough of contributed modules. They are so cool. You can do pretty much anything and that's exactly what I'm looking for: I want to be able to do anything I want. Every now and then I find a nice module install it and then, oh, use it or not. I have one hundred and sixteen contributed modules currently on my site of which maybe a third is enabled.

I installed a good few modules today and I wanted to enable the ones that seemed cool. While I was at it I reviewed the 116 modules that I already have there and enabled a few others that I already installed earlier. Then, thinking nothing of it, I clicked on the SAVE button.

KABOOOOM!!!!

500! Internal Server Error! ARGGGGHHH!!!

Right. So it could a coincidence and could be just the hosting.
I checked my FTP access. No problems there. I checked my database access. No problems there.

So it was something I did. One of the modules crashed my website.
I don't have a backup.

I mean: I do, from a month ago, the amount of changes I made since is unthinkable. So in theory I do, in practice I don't.

Time to panic.

I started to think frantically. Lit a cigarette. I can't access the website so how on earth am I going to disable the vicious module? There must be file or something that tells Drupal which modules are enabled.

Googled something like: list of modules drupal file help!  and found that there is a file called modules.inc that might have something to do with it. Checked modules.inc: No lists, but gave me a clue. A part of it says "function module_list" and is followed by this piece of code:

$result = db_query("SELECT name, filename, throttle FROM {system} WHERE type = 'module' AND status = 1 AND bootstrap = 1 ORDER BY weight ASC, filename ASC");

I silently blessed my previous job that forced me to learn SQL. The above means in simple terms that in table 'system' the rows with 'module' in 'type' column and '1' in 'status' column are the enabled ones. Since the 'status' table is binary, all I need to do is change it to '0' for those modules I want to disable. Simple! Off I went back to my database and two lines of SQL later my site was back up and running - with a few harmless errors that needed clearing, but running.

Lessons learned:

  1. take backups
  2. be more careful installing modules that had to be written by people therefore they have every right to be shit
  3. remember that everything can be a blessing in disguise, even a job that is rubbish, for every experience enriches us
  4. take backups

See, I do learn something new every day!

P.S. The module that caused the crash was Mobile Plugin that was supposed to optimise the website for mobile readers, who I have a few. Seems it doesn't like Apache servers. Oh well.

Mastodon