Updating the Backup Scripts

So, it’s been awhile since I actually looked at the code for my Backup Scripts.. I had been using them religiously for quite some time, but when I got rid of the server cluster that I had, I stopped using them.

Recently, I setup a server in the Azure cloud to run this website and a few others on. I figured, what a perfect use for the scripts!

Upon firing them up, I found several (no, really, pretty much every bit of code) pieces of the script needed overhauling as errors were thrown all over the place.

First thing I started with is the home-backup script. I used a really handy website called¬†ShellCheck¬†that assisted in the ‘QA’ of the code.

I think, it’s about time to start versioning the script, instead of just making changes whenever. I’m not sure what version it’ll start with, but compared to the original, there will be a lot of improvements.

First, I’m working on enabling the ability to call flags on the command, for example: “./home-backup -d /some/backup/dir -u some_user”. Which will make it easy to setup single user backups, instead of backing up everything.

Second, Error handling. Right now, the script doesn’t have any error handling at all. Since it’s a backup script, the only risk is, the script fails and no backup is taken. I’m building error handling around the backup destination, so that if the directory doesn’t exist, it will prompt you to create the directory. I”ll likely work into the script an automatic creation when using a flag.

Now, the mysql-backup script, will mimic the home-backup because they both go through the same paces.

So, the home-restore script.. This is one I haven’t really dug into yet. Obviously, the first thing that needs to be done is error handling and a “rollback” feature. Right now, it expects that all conditions are met, and just goes. This one, may take quite a bit longer to be “ready”.

For now, I’ve put the WebUI portion of this project on the shelf. Somewhere down the line, I might pick it backup and actually make it happen. But, for now, it’s on the shelf.

If you’ve got any bash experience, and wish to lend a hand, please by all means contact me!

Thanks for reading!

Dan

Garden Cam Gallery Project

For awhile now, I’ve had my Garden Cam up and running but I wanted a photo gallery that wasn’t a pain to maintain or setup. I also needed it to auto detect directories and photos. I stumbled across SFPG (Single File Photo Gallery) which does just that!

My only problem was, the webcam only uploads a single image every 5 minutes. My fix? a simple bash script to copy that file into a directory 1 minute after the new image uploads. The image starts at cam_1.jpg but gets transferred with date and time stamps on it for easier sorting with another bash script. Once it’s in the new directory and renamed, it gets sorted:

DATE=$(date +%m%d)
Dir=$(date +%m-%d)

# Move the files
for file in cam-“$DATE”*.jpg; do
mkdir -p “$Dir”
mv $file “$Dir”
done

I have the sort script run one minute after the file gets moved, this way I don’t have any issues with the sort script running before the image is moved.

So check it out Gallery

Something you may have caught onto if you read any of my posts, I do things in a round about way. Mainly because I don’t want to have to pay for software to do something if I can make it happen my own way. (prime example: My back up and restore script)

If you want to talk to me about my scripts or want to use them, feel free to contact me! (the ways to contact me are over to the right)