Don’t Screw Up: Preventing “Oh Sh—” Mistakes

The longer I perform day-to-day web design operations, the more I take for granted the reality that one accidental keypress can wipe out someone’s site. For those of you that don’t develop, I want you to hear that one more time:

One accidental keypress can wipe out someone’s site.

It’s true. On my editor, I have one tab for my local files, one tab for remote server files. If I’m accidentally in the wrong tab, any file I delete may be gone forever if I don’t have a backup on my computer. One thing I’ve done before: I’ve cleaned up files on the server, and I purposefully deleted a file. But what I didn’t realize was that I had accidentally Ctrl+clicked an entire folder, and stuff was dropping like flies from the server. Naturally, I panicked, but I was able to stop the connection and re-upload my local copy.

Still, I have accidentally over-written more code than I will publicly admit, and I vividly remember that distinct feeling of having all the blood drain from my face as I watch my screen in horror (if you haven’t seen this yet, this is worth watching: Pixar Studio Stories — Toy Story 2 Was Almost Deleted). But I learn (slowly), and I develop habits to prevent mistakes again. With that said, I’m working on an important site today, and to keep myself from completely screwing up, I’m brainstorming 10 good habits to keep when working on the web:

  1. Keep Backups. I know it’s painfully obvious, but back it up. Files, database, everything. Keeeeeeep. Backups. Back it up before you do anything, even upgrading a plugin. But backing up the database is a pain! No, it’s not. If you’re like me and hate phpmyadmin, look into Sequel Pro or Heidi SQL, and learn how to remotely connect to databases. It takes about 10 seconds to backup a database this way.
  2. Keep Backups. No, seriously.
  3. Check yourself. Before you do anything on server, ask yourself: am I doing what I think I’m doing? I find myself double-checking to make sure I’m actually downloading something instead of uploading it. If I’m deleting anything off the server, I make double-sure I have one and only one item selected. If I’m working with code, I make sure my code window is selected, and not my FTP tab when I hit my Delete key. Pausing a split-second before each action can save you hours of crisis management.
  4. Test your changes. Are you developing off your computer? Use xampp. Are you developing off a network with a server? Use that. Or copy the site to /dev in the server root directory and map it to dev.domain.com. Test your changes before pushing them live. Go nuts! Feel free to break anything you want to when an entire live website is not on the line. I only know one person who works live off a server, and he’s a 50-year-old code guru that writes fail-safes and self-mending code as he works. For the rest of us normal folks, set up a testing environment.
  5. Don’t delete files you don’t have to. Is a file not being used by the website? Leave it. Whatever. If it doesn’t affect site load time, and you have all the server space in the world, just leave it. But I like things clean! I understand. Some people like to make backups of backups of page templates that are the same file copied over and over again, scattered all over the server. Sometimes the same folder is copied into itself and 3 other places. I know not everyone is as professional (OCD) as you. But maybe—just maybe—that one file you think is useless is actually more important than anything you put on the server. So only delete things you have a good reason to.
  6. Use Git. If you’re not using Git for code, start now. If Terminals aren’t your thing, GitHub now makes clients for Mac and Windows, and even if you’re not posting code to the site it makes local Git repos a cinch. With Git, as long as you’re backing up properly, you can delete code left and right without worry. Can I just copy my files on my computer and save backup versions? Sure, whatever. You can do whatever you need to, but Git is waay easier, and really keeps the clutter down.
  7. Know the consequences of your actions. Basically, ask yourself: what is the worst possible outcome from doing this? If you’re writing a garbage cleaning script, did you set a filepath as an input variable? Are you really sure it won’t delete more than you might want? If you’re running a DELETE database operation, have you set a LIMIT? Are you sure it won’t delete more than you think it will? Weigh your actions, and try to make sure the worst case scenario is at least considered. But as long as you made backups, you’re good, right?
  8. Don’t overestimate yourself. Just like I overestimated my ability to think of 10 things.
  9. Keep Backups. Have you backed your sites up yet?
Drew Powers is a frontend developer at Envy.