2

I'd like to have a strategy to be able to make backup images of a Pi while it is running, but then have the option to restore that image to the SD Card in the case the system becomes unbootable or needs to be fully restored.

I found this article that shows how to use dd to create an image (to a NAS share over the network for example).

sudo dd if=/dev/mmcblk0p2 of=/home/pi/networkdrive/my.img bs=1M

However there is no guidance on how to restore, especially if the Pi is unbootable.

I'd like to be able to restore the .img file using a tool like Win32DiskImager. It defaults to .img files, but how can I determine if the .img file created by dd is the same as the .img file used by Win32DiskImager?

I've reviewed the Win32diskimager site, and it is not clear if the .img files are the same. Is restoring a dd img file to an SD card with Win32disk imager going to be successful?

  • Yes - restoring an image is as simple as writing the img file to SD card using Win32diskimager. I do this all the time so I keep snapshots of my testing progress. As far as doing live backups, I think that's a little trickier - you might be able to do that with a NAS device - or a USB SD card reader, but I personally shutdown the Pi and save (read) the image while offline using Win32DiskImager – dbmitch Nov 20 '16 at 23:54
  • I would use piclone: sudo apt-get install piclone. but that only works with a GUI. – sir_ian Nov 21 '16 at 1:27
1

Yes, and no.

If you make an image correctly they would be the same, although making an image of a live system will have more rubbish, and is subject to any changes made while dd is running.

The command, as listed, will only make an image of 1 partition. If using Rasbpian this will probably be your root partition, but the boot partition and partition table will be missing.

See Can a Raspberry Pi be used to create a backup of itself? for a viable backup of a live system but this may not work to a network drive - it does to a mounted drive.

0

Just to add my little contribution when you dd stuff here is how you know how it's working: dd if=input_file of=output_file bs=4M

"if" stands for input_file. That means it's the file you want to copy and "of" stands for output file. In the end. dd is only a kind of raw copy that will copy whatever you like be it file, image, memory, hard drive to another memory space.

You can reverse it very easily, by doing the opposite, it will keep the encoding AND the file as they exactly are.

"bs" is buffer size, since 4M is the size of a page in most Linux distro it seems to be optimized for most distro to use, but you can set whatever you like if you want to, you will feel the difference only if you copy huge file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.