Backups: Everyone Needs them

by | May 21, 2021 | Tech Geekery | 0 comments

I originally posted this on 14 October 2016, and to this day, I can still feel the icy claws clenching my heart as I realized what I’d done.

So…as part of my day job, I write a series of articles about technology issues, and a few months back, one of my article topics discussed the importance of off-site backups and the various methods one might use to achieve that worthy goal.

Today, I would’ve loved to have had an off-site backup of my web server. Yes…the very server that is allowing you to read this composition.

Here’s how it happened.

The company where I work is so generous and forward-thinking that there is one hour every workday blocked out for professional training. My supervisor (who also happens to be the kind of friend I name family) specifically told me to “pick something that will better you in your job, and study that.” Full disclosure: that’s not a verbatim quote, but the intent and spirit of the statement is there.

I decided that I was going to start studying the WooCommerce module of WordPress, so I logged into my personal web server (so I would not risk any company files) and was going to set up a WordPress site as a testbed for exploring WooCommerce.

After logging into my web server, I downloaded the latest release of WordPress to it and was going to make a database and folder structure for the new WordPress site. However, I remembered that I still needed to delete the “config” folder of my phpmyadmin site, so I did a quick command to delete that folder:

sudo rm -rf /WEB DIRECTORY/phpmyadmin/config

…and this was the point that the rails kinda came off my plan.

For those of you who are not familiar with Linux, “rm” is the command to delete whatever you type after it. “rm -rf” is the command to delete all files and subfolders of whatever you type under it.

My goal then became to look at the contents of each site’s web folder, but I was lazy and sloppy. Instead of typing the proper command, I tapped the Up arrow and was going to edit a command a few lines up.  I should’ve just typed it by hand, because I executed this command:

sudo rm -rf /WEB DIRECTORY/kfp

This is the command I should’ve typed:


Now, since I obviously didn’t see a listing of files and subfolders appear on the screen, I thought to myself, “Huh…well, that’s odd. What’s in the folder above it?” And I proceeded to tap the Up arrow once and pressed Enter to execute this command:

sudo rm -rf /WEB DIRECTORY

Yup…I did that.

A few heartbeats later, when I truly processed what I had just done, I felt embarrassed, stupid, and…well…Not Good. It’s not a problem, though, I could just pull the files from the backup, right?

Yeah, about that…

System backups have been on my to-do list ever since I re-worked the web server to use Apache instead of NGINX. The key phrase in that statement is “my to-do list.”

Luckily, I made copies of all my website files and MySQL databases in the process of re-working the server to run on Apache instead of NGINX, which meant that I had a mostly current copy of everything. All the websites that run on my server are back up and functioning now, and I’ve spent this evening creating a mechanism to backup my website files and MariaDB databases (I also migrated to MariaDB when I switched to Apache).

To achieve this, I found a template for a shell script and wrote two scripts to create backups of both my website files and my MariaDB databases with the time and day they were made in the file name.  Then, I used cron to schedule these scripts to run every day at 1am.  Since I didn’t want my hard drive filling up with backups, I tracked down a command to delete all files in my backup directory except for the last seven.  It parses output from “ls,” the command to list directory contents, which can be risky in certain circumstances, but I’m willing to risk it for a week.

Maybe by next Sunday, I’ll be in a mood to fight with mounting an Amazon S3 bucket as a network drive.  Come to think of it, though, I never did build that test WordPress site to start learning WooCommerce…


Submit a Comment

Your email address will not be published. Required fields are marked *

The reCAPTCHA verification period has expired. Please reload the page.