Backup Raspberry Pi

Why Raspberry Pi ?

About a year ago I received an Raspberry Pi model 2b to learn programming. It’s a small “computer” with a lot of interfaces. Not only network, usb and also GPIO etc.

But instead I used the Raspberry Pi to track my solar panels with MRTG and I created a script that disabled my Access Points when nobody was at home. (To save energy. Why have your AP up and running when nobody is using it ?)

My Raspberry Pi Mode 2b

My Raspberry Pi Mode 2b

Samba server.

Because there were 4 USB connections at the RP, I connected my smart meter and an external HDD. The setup of a Samba server is very easy. A good link is : Samba-Deploying

But….. the network connection on the model 2b is only 100/10 mbit.. This is slooooowwwww !!! So I bought an 1000 mbit USB ethernet cable for Euro 1.83. Of course I can’t get the full 1000 mbit, but at least its fast !


Backup your Raspberry Pi

Because I made some mistakes, I lost all my data on the SDCard and of course I didn’t had any backup. How to setup your RP to backup frequently.

You can use the command :

sudo dd bs=4M if=/dev/mmcblk0 | gzip > /media/USBHDD1/shares/raspbianBackup1.img.gz

It’s compressed with gzip. It will take some time before the raspberry is finished, but it saves space. It took about 100 minutes to finish.

If you don’t want to compress it just use :

sudo dd bs=4M if=/dev/mmcblk0 of=/media/USBHDD1/shares/raspbianBackup1.img.gz

It took me about 84 minutes before it finished. So be patient.

But this is only manual. What if I want to schedule it monthly ?

sudo crontab -e

for the firsttime you should choose your editor. Nano is alright.

I am using a small script with the command above. Just add at the end of the file :
0 0 1 * * /media/USBHDD1/shares/

This wil create every 1st of the month at 12:00am a backup to, in my case, external HDD. If you put more instances into crontab, it will be scheduled more often.



The Raspberry Pi mode 2b isn’t fast, but everything is working like it should be and it consumes very less power compared to my old servers.

Leave a Reply