Goodbye Raspberry Pi 1, welcome Raspberry Pi 2 ! (for now)

Posted on 2016-04-09. Filed under: Uncategorized | Tags: , |

Finally upgraded my old and dusty RaspberryPi git/backup/crashplan server hardware to newer version , runs four times as fast now, memory doubled, sweet! :-)

I guess RPI2 will be sufficient for a while, no need to have RPI3 for this setup for now :)

rpi2

Advertisements
Read Full Post | Make a Comment ( None so far )

Raspberry Pi : Easily backup system partition (with progress bar, ETA)

Posted on 2015-08-13. Filed under: Uncategorized | Tags: , , |

Wordpress - raspberry pi backup-1

Intro:

The goal is to create a simple script to automagically backup the entire SD card (including all partitions)  with some additional features:

  • display progress bar, speed meter (kb/s)
  • use compression to save space on target device (the one the backup is created in)
  • automatically name backup files so that they do not overlap
  • automatically pick the block device to be backed up

Step 1: Out of curiosity: Find the SD card you are backing up.

Use “lsblk” command to find all block devices:

root@raspforwarder:/home/test# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 931.5G 0 disk
└─sdb1 8:17 0 931.5G 0 part
  └─truecrypt1 (dm-0) 254:0 0 931.5G 0 dm /mount/secret-data
sdc 8:32 0 931.5G 0 disk
└─sdc1 8:33 0 931.5G 0 part /media/usb1
sdd 8:48 1 59.6G 0 disk
└─sdd1 8:49 1 59.6G 0 part /media/usb0
mmcblk0 179:0 0 3.8G 0 disk
├─mmcblk0p1 179:1 0 56M 0 part /boot
└─mmcblk0p2 179:2 0 3.7G 0 part /

Above, you can see my raspberry setup with two usb hdds (sdb,sdc, 1TB each, one containing a truecrypt partition) and one usb stick (64GB). Check out the mountpoints, partitions etc.

The device we want to backup is the mmcblk0 marked as “disk” – which is the sd card plugged in our raspberry’s card slot.

Step 3: Install the “Pipe Viewer” (pv) tool:

 What is pv ? Check this out.

root@:# apt-get install pv
 Reading package lists... Done
 Building dependency tree
 Reading state information... Done
 The following NEW packages will be installed:
 pv
 0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
 Need to get 0 B/36.1 kB of archives.
 After this operation, 136 kB of additional disk space will be used.
 Selecting previously unselected package pv.
 (Reading database ... 63655 files and directories currently installed.)
 Unpacking pv (from .../archives/pv_1.2.0-1_armhf.deb) ...
 Processing triggers for man-db ...
 Setting up pv (1.2.0-1) ...
 

Step 3: “One line to rule them all”: create simple backup script:

Create backup_raspberry.sh file with

echo creating backup...
dd bs=1M if=/dev/mmcblk0 | pv -rabep --size `lsblk -b | grep mmcblk0 | grep "disk" | awk '{ print $4 }'` | bzip2 > /media/hdd/backups/raspberry-backup-`date "+%Y%m%d"`.img.bz2
echo done. 

Step 4: Watch it run, have fun!

rasp1

Sidenotes:

  • It won’t hurt to make it cron job (make it run say, every monday ?)
  • To prevent the target drive from running out of available space pair above with tmpwatch to remove backups which are too old (2 months?) – but ONLY after the newest backup was successfully created.
Read Full Post | Make a Comment ( None so far )

Liked it here?
Why not try sites on the blogroll...