What a weekend.
I’m in the process of migrating servers, I’m moving from one hosting company to another. I have a number of different sites, one is still on the old cloud-based server, while this one, among others are hosted on our new server. I’m still doing a lot of tweaking, testing and securing before fully migrating everything over…and on the to-do-list is whole process for backing up, with a number of fail-safe’s in case anything goes wrong once all is migrated. The problem? It was still on the to-do-list.
So on Friday afternoon, I’m working on the server…I’m usually very cautious about working on it because I’m no system admin. I have separate access for different domains, that way if anything is compromised or anything goes wrong, worst case scenario is that it should only affect that one domain. During some of the work, I had to access multiple files from different domains, so I decided to login using root access, which can pretty much access anything and do everything.
To make a long story short, I was trying to delete the contents of a folder, and I used the following command:
rm -rf folder /*
I meant to do:
rm -rf folder/*
The difference of that one space? Rather than deleting everything within the folder, it deleted the folder AND everything in /…which for Windows folks, is like saying delete C:\. Seconds later and if you went to any of my sites you would get a quick error back saying permission denied. On top of that, I hadn’t implemented my backup system yet, so I had no backups. Talk about a nightmare!
The entire weekend was spent figuring out a variety of solutions to get everything restored to as close to the date as possible. I got lucky with a couple things, like having a backup of some databases that I had downloaded while migrating servers (couple weeks old), and a recent backup in my recycle bin. At the end of the day, after much wasted time, I was able to get everything fairly close to restored as possible (I did lose some stuff). The first to-do after that? Back everything up! Had I not had certain files downloaded, or my host hadn’t had a disaster recovery file from a month prior, the situation could have been much worse.
This is a reminder to all site owners. You never know what can happen. Setup a backup plan, and implement it yesterday.