[Linux] auto backup git repos when USB device is inserted

One thing I have always struggled with is finding the time to make backups.

You don’t always want to automate this over the internet for various reasons and might want to backup to an external drive that you can stash away safely.

Recently I decided that my home git server should be backed up and stored elsewhere, off-site.

Making sure to do that regularly can be an effort, particularly so, when you run a headless server. Sure, its as easy as turning on a nearby PC, SSH in and run the backups, but I’m lazy, so there has to be an easier way.

What I’d really like is to plug in a specific USB storage device that I’ve allocated to backups, and when I do so, it will trigger backups automatically and better yet, let me know somehow when it is done, after all, this is a headless server (meaning it has no monitor, or a keyboard and mouse connected).

The answer, in this case is; “udev”. Note, it’s not the only answer, “systemd” is the new kid on the block and perhaps later I’ll update with a systemd implementation.

What I have put together is a way to launch a script when the serial number of a specific USB drive is plugged in and detected. For this, I use “udev” (documentation). “udev” is a dynamic device management tool that allows you to perform actions on device events.

In this case, the “rule”, which is what we call the configuration file that performs the detection waits for a device of the USB kind, checks for a serial number that matches one we set (well find this using some other tools later) and then performs an action we tell it to. In this case, we want it to run a script to backup our git repositories.

The rule can be made to run any script you like, it doesn’t necessarily need to be a git backup, nor need it be a backup script at all. It could he used to start a program like a web browser, or a photo editor when you plug in your camera. Simple replace the git backup script later on with your own, and you’re good to go.

Continue reading

Serial Commander 1.0 – Arduino UART Command Library

Sadly, this post won’t be as image heavy as I like to make them. On it’s own, there is little to show, but the thing that’s really exciting abut this simple library is that it allows me to update Pixel Commander to a point I consider ready to continue the project I’ve spent a long time procrastinating over.

Serial commander is intended to be an easy to use, serial command library for controlling your Arduino projects.

Sending a command to your arduino can be as simple as writing;


and having your Arduino return;

Hello, 2bytes

Continue reading

Raspberry Pi B and B+

Raspberry Pi B vs B+ Power

With the recent release of the Raspberry Pi B+, I was lucky enough to be working right next to Westminster bridge where the very kind Element 14 were giving out free Raspberry Pi B+ and Ice Cream, both of which I managed to get my hands on, thanks guys!

One of the key factors that interested me with the new Pi was its move to more efficient switching regulators instead of the old linear (read: inefficient) ones it had before. This move, the Raspberry Pi Foundation tell us lowers the power consumption of the little board noticeably.

Being that I tend to run my Pis 24/7 (I now have a Pi Running OpenVPN, and a Pi running Seafile), the smallest difference with this relatively low power device should be significant.

Seafile had proved difficult on the B, as there are difficulties powering external HDDs from its restricted USB current output, the B+ promised to solve this, and I can tell you that it delivers! Read on for the numbers!

Continue reading

Open Logic Sniffer Case

Open Logic Sniffer Case

So this story beings quite recently, when, being the ‘noob’ that I am, I reversed the polarity while setting up the Linksprite UART camera ready for another post. Sadly, I had my bench supply set to unlimited current. Well, long story short, the camera is dead. Sad times, because beyond the first post I made about it, I haven’t even had a change to use it yet.

Well, having destroyed my latest toy, I thought I’d buy a new one to make up for it. No, really, I needed the tools to try and repair the camera, and well, I needed a Logic Analyser.

Continue reading

Pixel Commander – Arduino UART RGB L.E.D. Controller

Pixel CommanderPixel Commander is part of a much larger project I’m currently working on. Its purpose is to allow me to remotely control one of the LED boards shown in the image (the board design will also be open sourced when it is complete).

Pixel Commander takes commands over UART and uses them to change the state (colour, brightness) of the LEDs on the board.

Continue reading

Linksprite Arduino

Linksprite JPEG UART Camera + Arduino

Here is a small piece of code I threw together with help from the original source from Linksprite allowing me to interface with the Colour UART Camera from an Arduino board, over SoftwareSerial.

The reason I went for software serial is that this particular Arduino is to be used as a single node in a larger “internet-of-things” and the hardware serial port is required for communication over the XBee module that will be attached, to other nodes in the network.

Firstly, I’ll start with a diagram of the hardware. In this case I’m using a 3.3V Arduino Pro Mini. The voltage is critical, because the camera will need to run at 5V to be reliable. Fortunately, the Arduino is capable of regulating the voltage to it’s required level if it’s connected up right!

Continue reading

Bits & Niggles: Dialogs

Dialogs are a necessary part of Android development, prompting the user for a Yes/No action is often required by applications of various types.

The Yes/No answer to these dialogs is usually of some importance, for example; “Are you sure you want to erase every single photograph you have ever taken?” and the Answer can often be “No”, because you clicked on something accidentally or because the UI design didn’t make it entirely clear what action you were about to perform, but that’s a story for another day.

Continue reading