Raspberry Pi – BMR

Raspberry Pi – BMR (Bare Metal Recovery)

The raspberry PI safely backup, although we all like to have individual files restore capability and we all like to be able to get the system back as soon as possible it’s not always possible with one type of backup and there for I’ve created this script that I like to call the BMR for Raspberry PI.

This script is written in shell scripting language so easy to digest, view, modify and update as you see fit but also ready to run it as it is will a single modification… The target folder.

As this backup script will create a backup image of your SD card keeping everything exactly the same way with the contents and settings it would be easy to bring back your Raspberry PI fully to the same point as it was at the time of the backup.

* Quick and easy to rebuild your Raspberry PI fully as it was before

* Additional storage device USB card / drive / disk required
* Additional storage device needs to be larger than the primary SD Card

* Additional storage device must support large files (Recommend ext4)
* Script assumes user (pi) can run “sudo” with “NOPASSWD” enabled.
* You must update DESDIR variable in the script.


pi@bkp:~ $ mkdir scripts
pi@bkp:~ $ cd scripts/
pi@bkp:~ $ wget -O raspbian-bkp-img.sh goo.gl/hPcKk5
pi@bkp:~ $ chmod +x raspbian-bkp-img.sh


Download it from this link and save it manually.

30 1 * * * /home/pi/scripts/raspbian-bkp-img.bash >/tmp/bkp.img 2>&1

OR without any output logs

30 1 * * * /home/pi/scripts/raspbian-bkp-img.bash >/dev/null 2>&1


* Mount USB with image on a working raspberry / linux system (sda)
* Mount new SD card on the same working raspberry / linux system (sdb)
* Example command:

pi@srv:~ $ sudo dd bs=4M if=raspbian-srv-2017-11-06.img of=/dev/sdb

* unmount (sdb) from raspberry / linux system & insert it into the dead raspberry PI, power one.

All gone well you now have a perfectly working Raspberry PI again everything exactly the same way with the contents and settings from before.

Here are a couple of screenshots to show it in action.

* Can not create a Raspbian image backup directly on the SD card itself

* Successfully run a backup

* List of backup created

* crontab example of a daily backup at 01:15AM

* Updated to include compression – Tue 7 Nov 22:23:04 GMT 2017

Enjoy it and please let me know what you think @gcclinux on twitter