MicroSD backup

Once we have a stable system on the microSD card of the Raspberry Pi, we make a backup snapshot of the card periodically. These cards can become corrupted. At present, we are making backups by hand: power down the RPi (sudo shutdown -h now), remove the microSD card, place it in its adapter, insert it into the SD card slot on redhen1, use Pi Copier to make an image of the disk, stored in ~/Documents/IMAGEof_redhen3rpi_SDcard. But this requires the physical presence of some human being.


Find a safe way to take a snapshot of the microSD card remotely, without powering down the Raspberry Pi or removing the card. For information on making such snapshots, see https://www.raspberrypi.org/documentation/linux/filesystem/backup.md . Can we actually make an image of the very card that is running the process? Perhaps the resulting image could be placed on the external hard drive connected to the Raspberry Pi, and then establish rsync between a directory of backups on the Raspberry Pi and a directory on redhen1.case.edu.

Would you like to accomplish all or part of this task?

If so, write to

and we will try to connect you with a mentor.

Status: solved

Solved by this web page: http://cagewebdev.com/index.php/raspberry-pi-creating-a-backup-image-while-the-raspberry-pi-is-running/

Raspberry PI – creating a backup image while the Raspberry PI is running

How to create a backup image of your SD card while your Raspberry PI is running?

You can create a backup (.img) of your SD card to a network / USB drive while the card is inserted in your Raspberry PI!

  • make sure you have access to your network drive / usb drive;
  • to see the devices type:
  • sudo cat /etc/fstab
  • create an img of the card currently in the PI to your network drive / USB drive using the dd command:
  • sudo dd if=/dev/mmcblk0 of=/home/pi/networkdrive/my.img bs=1M
  • or with full bells and whistles, include the size of your SD card and use the pipe viewer, pv:
  • sudo pv -tpreb /dev/mmcblk0 -s 30908350464 | dd of=/home/pi/networkdrive/my.img bs=1M conv=sync,noerror iflag=fullblock

E.g., our command would be

sudo dd if=/dev/mmcblk0 of=~/HD1/IMAGEof_redhen3rpi_SDcard/redhen3rpi2015-11-16.img bs=1M

or with pipe viewer

sudo pv -tpreb /dev/mmcblk0 -s 30908350464 | dd of=/mnt/HD1/RPi_backups/2015-12-12_fenix.img bs=1M conv=sync,noerror iflag=fullblock

And it works: 30845435904 Nov 16 15:34 redhen3rpi2015-11-16.img

We can also copy this to redhen1: scp -r IMAGEof_redhen3rpi_SDcard USER@redhen1.case.edu:~/Documents/.

And it works: 30845435904 Nov 16 18:21 redhen3rpi2015-11-16.img


We now use an excellent community-developed backup script at Github, which implements the pipe viewer command and also updates packages before the backup. The script can be set to perform a daily backup from cron.