Back up. Stress down.

Here’s a simple backup script to drop onto your Linux based server. It’ll back up and rotate file names, once a day.

I wanted something simple but powerful. It just requires the ubiquitous date command, present in most systems, but will keep enough backups to cover most situations. One per month over 12 month rotation, one per week over 5 week rotation, and one per day over seven day rotation.

The code simply uses the fact that the days and months change in a predictable way. For instance Monday comes around every seven days, so a file called Monday will be replaced every seven days if we try to save another file called Monday, as with all the days, simply replacing older files.

It’s on my BitBucket here:
which you can check out for more details. But also see the code below.

backup_rotate_store () {

	local usage
	usage="Usage: 'backup_rotate_store <directory> <original_filename>'.
The original file should be in <directory>. Pass in the current name of the file."

	# Check for parameter $1
	if [ -z "$1" ]
		echo "First parameter not set to a directory"
		echo "${usage}"
		return 1

	# Check for parameter $2
	if [ -z "$2" ]
		echo "Second parameter not set to original filename"
		echo "${usage}"
		return 1

	local directory
	local original_filename

	local DAY
	DAY=$(date +%A)

	# Day backupds (Sunday, Monday, etc.)
	mv "${directory}/${original_filename}" "${directory}/${DAY}.${original_filename}"

	local DATE=
	DATE=$(date +%d)
	if (( $DATE == 1 || $DATE == 8 || $DATE == 15 || $DATE == 22 || $DATE == 28 )); then

		if (( $DATE == 1 )); then
		if (( $DATE ==22 )); then

		# Weeks backup (1st, 7th, etc.)
		cp --archive "${directory}/${DAY}.${original_filename}" "${directory}/${DATE}${EXTENSION}.${original_filename}"

		if (( $DATE == 28 )); then
			local MONTH
			MONTH=$(date +%B)

			# Months backup (January, February, etc.)
			cp --archive "${directory}/${DAY}.${original_filename}" "${directory}/${MONTH}.${original_filename}"


To use it, just move the file to backup to where it should be stored then call the function. e.g.:

echo "My backup testfile" > testfile


mv testfile "${DEST}/${FILENAME}"

backup_rotate_store ${DEST} ${FILENAME}

Enjoy, and may it bring you luck.

Share This:


In July of last year I purchased the LG Optimus 3D, a mobile phone which comes with dual cameras to take spectroscopic images. I’ve been very happy with the camera and consequently have quite a collection of 3D images. However, there are no easy ways to display the 3D photos online – this is why I created “StereoImage”.

StereoImage is a way to display stereoscopic images on a HTML5 canvas. It works on jps and pns files which are fundementally two jpegs / pngs joined together side by side. Using StereoImage a user can quickly switch between different ways of displaying the images.

See it here:

Your browser does not support the canvas element.

The different ways to show include:

  • Horizontal, one on top of the other,
  • Vertical, side by side,
  • Show just the left,
  • Show just the right,
  • Flick between both images (at variable rate)
  • Stereoscopic – reduce size with circle eye alignment.
  • Anaglyph – red and green/blue view (for use with glasses)

The code is open source, so feel free to use it. You can find more details on my website here: . Download or checkout the code via BitBucket here:


Share This:

The Samsung Running App

The samsung running app (called “Samsung Hope Relay”) is a nice idea. Samsung will donate a pound to charity for every mile you walk, run o4 cycle (and probably anything else under a 20mph…), but it records distance so no point using it in the gym! It is a little buggy though:


But hasnt stopped them giving £200’000 so far. Get it quick before the Olympics and raise a bit of money (and probably loose a few pounds!)

Share This:

Laser eye day

Just a few hours till my Laser eye surgery… and yes I’m a little nervous. It’s been booked for about a month, but I’ve been so busy I’ve not really given it much thought – but as it’s a approached I’ve been thinking about little else.

I’ve gone through all the material they’ve given, and it explains the whole procedure, interjected with: “This horrific thing could happen” (Eeek!) “but it’s quite rare”… It isn’t really a pleasant read, but a couple of days later you start to understand what will happen on the day and become a little more calmer about it (or possibly just forget all the bad stuff) – if you are having the procedure, don’t leave it to the last minute to read it!

Share This: