Saturday 8 November 2008

My Backup Solution

Last night I put the finishing touches on my little backup system for my home network and it all works!

About 2 months ago I grew annoyed with the fact that I had no real backup system in place for my gear, I decided that something needed to be done. I did a quick search for backup schedulers and didn't find anything out there that tickled my fancy, so I thought "What the heck, I'll build my own."

It consists of a daemon on a server computer (which I wrote in C) and a little Python script on each computer in my network (written for me by my good friend Steve as I lack Python skillz).

The daemon comes up when the server boots and sends a broadcast packet to let everyone know it is awake and ready to receive files, each host then sends the server a request to join the backup queue. The server works through the queue, starting what I call the backup transaction with each host in the queue in turn; first it sends the host a "backup now!" packet, the host sends the compressed backup files then tells the server when it's done. The daemon then moves on to the next client in the list. Basic stuff really. But it took me ages to get right...

The daemon should compile on a Linux box (well, I hope so, it compiled on mine...). The log directory needs to be set to somewhere that is writeable by the user you run the executable with obviously.

I'm not going to be so arrogant as to say that my code is perfect, it isn't. I'm putting it up here to show everybody and to learn from your comments. Don't insult me too much please :P


Here goes:
BUddyd.c: http://pastie.org/310236
BUddy.py: http://pastie.org/310981

The "auto client" I talk about is an edited version of the BUddy.py script that listens for the broadcast packet and then joins the queue. I'm just sticking with the manual way for now.



6 comments:

Steven said...

You need to host these somewhere else and link to them. Indentation is sort of important in Python and your includes are being interpreted as being HTML tags.

Moley said...

Thats the only helpfull comment your going to get because Steve is the only person who reads your blog that knows how to code.

Joshua Lockhart said...

yeah, I'll edit now.

Steven said...

What was the point of hardcoding the server address in the client script?

Joshua Lockhart said...

aw crap I forgot I did that...

That was my quick fix a couple of weeks ago so I didn't have to make it depend on the broadcast thing, after your mocking about my disregard of the traditional client server model :P

Steven said...

Idiot.