*Disclaimer: I can follow directions for Terminal, but I am not a nix user by default.

I have a Raspberry Pi that I just had to restore. Before I get anything else installed I would like to create a clone image that I can restore if required.

I have done this by inserting the SD card in my Mac and using the following:

sudo dd if=/dev/rdiskx of=/path/to/image bs=1m

If I SSH from my Mac, can I create a clone across the network to my machine? There is not enough room on the SD card to do it locally.

up vote 3 down vote accepted

Have a look at my instructions here for using rsync to maintain a backup; at the end there is a brief paragraph about using it via ssh.

If you pay heed the part about what should go in the rsync-exclude.txt list, you can do this while the pi is running. You can also use -e in place of the --rsh I use in the other example, or if you have no special options you need for ssh, just omit it; rsync will use it by default when it sees a network address. So:

rsync -aEv --delete --exclude-from=/rsync-exclude.txt root@yourpi.ip:/ /backup/path

Updates the backup. Using it to restore is explained in the other answer.

  • have you really read the question? how do you propose to create an SD card image using rsync? – lenik Feb 20 '14 at 23:43
  • I did try your suggestion, and got it to work (with a few changes). However there are issues, and I doubt it could be used to restore (at least by anyone without extensive Linux knowledge) raspberrypi.stackexchange.com/q/13611/8697 – Milliways Feb 21 '14 at 0:45
  • @lenik : I read the question. I was responding to the desire "to create a clone image that I can restore". If people are determined to use dd as a backup tool, that's up to them, but at the same time -- just like a question with posted code containing an obvious programming faux pas -- it should be indicated that this is the canonically wrong method and provide a more normative, orthodox alternative. Hopefully this at least helps to prevent other people being led astray: "Oh, here's a question about how to back up my pi" -- no, this is a question about how not to back up the pi. – goldilocks Feb 21 '14 at 6:28
  • Thanks Goldilocks! Appreciate the info on using rsync over dd, and the details instructions! I am hoping to get to try this today, but it's looking more and more like it will be next week. – Kray Feb 21 '14 at 14:16
  • @Kray : You'll need rsync on the Mac side if you are doing it from there -- I'm not a big OSX user, but it appears to be standard equipment, fortunately. It maybe a slightly older version than is used on raspbian/linux/the pi but the man page matches up. – goldilocks Feb 21 '14 at 14:26

it's possible to run ssh to issue a command on the remote end and catch the output on your local machine, something along the lines of

ssh user@192.168.xxx.xx 'dd if=/dev/mmcblk0 bs=10M' | cat > sd_image.img

but actually it's not recommended to read SD card while the system is running from the same SD, because it's very easy to get an inconsistent file system image and you'd much better off using SD card reader on your Mac for creating images with the command you shown above.

The problem with a dd-created image is: you can only write it back to a mSD card that is larger than the image. So if your image is 16GB, trying to write the image onto another 16GB card may chop off some sectors, because the new card has a few sectors less than the old card from which the image was taken. Trying to write an "oversized" image to some USB sticks or mSDs may brick them, as I found out the hard way.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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