1

I have 4 Pis. On each Pi I have mounted my Airport Extreme (Apple router that has built in storage) to /home/pi/Airport. I would like to automatically backup each Pi on a set interval. Would doing something like dd if=/dev/root of=/home/pi/Airport/image.gz be dangerous with the network storage mounted? What would be the proper way to clone the Pi from itself and copy that image to the Airport Extreme?

K. Shores
  • 113
  • 1
  • 5

2 Answers2

3

You can use dd on a Linux machine to write to any mounted storage. This writes raw blocks, so should work.

Restoring the image files is another problem.

NOTE There is no such thing as /dev/root. On the Pi the SD Cards is at /dev/mmcblk0

You probably need sudo to grant dd the necessary permission to access the devices.

Milliways
  • 62,573
  • 32
  • 113
  • 225
3

It is not a good idea to take an image from a running system. During backup the system will dynamically change important system files and caching so you do not get a consistent backup. It is not guaranteed to restore a running system because system files may not match.

This is a well known problem and you have to take some effort to avoid this. The easiest way is to boot into read only mounted file systems but mostly not practicable.

You can look at Can a Raspberry Pi be used to create a backup of itself? how to use rsync to update a running system.

If you like to take one time some effort then you can do very simple backups like you intend to do. You can use logical volumes, just make a snapshot and backup the snapshot. How to do it you can look at Easy backups and snapshots of a running system with LVM.

Ingo
  • 42,961
  • 20
  • 87
  • 207