IoT your mother...

This article is about my backup system project, because it is pretty cool… and nerdy :-)

I have a NAS (Network Attached Storage) where I pretty much save everything. This system is set up as a RAID 5 system so redundancy is guaranteed. But is my data safe? Well it is better then having it on my PC only, but no it is not safe.
Some really important (for me) stuff like my pictures and source code have been migrated to cloud services, but I still think it is too expensive to do that for all my stuff.
Apart from the expense I also don’t trust all the services to be careful with my privacy or the countries these cloud services reside in.

So I thought of a project where I could play and still create something useful. This article will explain how I created a remote backup (stored at my mothers house) and how I made it cost minimal.

Oh and I have thrown in some IoT just because I can.

Journey

A few years back I wanted learn how to control the physical world through programs. Right at that time I heard about the Raspberry Pi and I can tell you that little computer gave me back all the joy I had as a kid playing around with my commodore 64.

I wanted to be able to control an outlet in my home as my first trial. No I had no reason to, I just wanted to. I live by the JustBecauseICan principle 😄.

After a few month of trial and certainly error I came up with the following solution.

As you can see in the movie it is not a really difficult piece of hardware I soldered together, but if you are a complete n00b (like I was) at electronics it is actually quite daunting.
I even broke a RaspberryPi during this process as I learned about peak-current and the like.

The journey to get this little piece of hardware running and functioning correctly was fun and fraught with mistakes, but hey that is how I learn best.

I learned about switches and GPIO and resistors and the like. Not really good as you can see in the picture below.

I tried to order some resistors and I was convinced I did it right of course, but when I received them I found out that there is still a lot to learn. The small one is like the ones I need and e big one was uhh the one I got. This is one of the reasons it took months in stead of days to make.

I also learned about current and when you flip a switch even if done by software you can create a peak-current. I found out that little computers don’t like peak-current, no no no not at all. So I fried a Pi. Ordered a new one and started paying attention and asking for help.
Sometimes I need to feel it before I believe it 😂.

One colleague (thanks Marco you know who you are) took one look at my schema and explained to me that it was ok but that I would blow up my Pi. Of course I did not tell him that I had already done that, so looking wise and interested I asked him if he could improve on it. He did. First he told me how to fix my schema and then explained that I could throw that schema away and just use optocouplers. Never heard of those! These optocoupler thingies are like switches but act on led light and the circuits are completely separated. So no peak current to be scared for. The schema became really simple after that. I had to order them though and that took some time…

When finished I gave a small demo on the first RaspberryPi Jam in The Netherlands hosted by Ordina and after that I forgot about it as I had no practical purpose for it. So it slowly started gathering dust and moved to a shoebox in my attic.

I’ve just revived it 😎 for my backup system. It is a second generation raspberry pi (old / 2013) that has actually seen better days. It has the standard sd-card (not micro-sd) slot which has been broken at some point. Luckily I had also bought a box for the pi and could jam a “credit-card” like card under it to hold the SD card in place. Just to be sure I hot-glued it there 😄 as you can see in the picture below…

Now I think I have all the ingredients to create a remote backup system.

  • A computer with linux so I can access it remotely and automate stuff
  • Backup drive
  • Option to remotely turn on or off something.

IoT your mother…

What I wanted was to have an off-site backup system installed at my mothers place:

  • Ethernet cable connected (stable)
  • only SSH access (also rsync / scp) through public-private key
  • option to turn off the disk remotely
  • option to turn on the disk remotely
  • completely manageable from home
  • Scripts to backup the most important folders to the off-site from NAS
    • login
    • turn on disk
    • mount encrypted backup disk
    • backup
    • flush to disk
    • unmount
    • turn off disk
    • logout
  • Install it at my mothers place

Start making it happen…

I started at home by plugging in the set as I would do at my mothers place. Testing at home is much easier 😄 and faster.

The setup:

  • 2 TB sata Internal HD on an external mount. Lots of space for much less than an external drive and I had these already available.
  • Click-On-Click-Off system for the outlet of the harddisk power supply
  • RaspberryPi directly into a permanent socket (will always run, or at least for now) As it uses very little power I won’t make an issue off it in the first iteration
  • bash scripts to perform backups. The code for this project as I go along with it can be found here.

The whole setup seems to work fine.

current status

A few weeks of testing and then probably start on implementing some new features like:

  • creating a nice box for the whole setup an actually install it at my mothers place.
  • health checks for nas on progress of backup and to check of service is still up.
  • log to a rest endpoint in order to get easy feedback
  • better interfact to add new things to backup
  • create a cron job or “scheduled task” on my NAS to automate this process even more.

Update 2018-03-25

I just found out that after almost a week of running the first backup that I synced a bit too much. My 2Tb disk was full and aborted the rest of the backup.
Ha I need to be more careful of what I really want to backup.
The scripts do seem to work though as the disk was dismounted nicely and the the feedback was clear.

So I have a new future feature request :-) I need to have some feedback about diskspace. So when I have some time…