5

I'm currently working on a Raspberry Pi 3 Model B+ with Raspbian Stretch, and I have installed several libraries such as TensorFlow and OpenCV. These installations took quite some time to do, and I wouldn't want to do them from scratch again if in case something happens to my SD Card or my Pi. I know that Raspbian Stretch came with a built in "SD Card Copier", and I was actually able to clone my 32GB SD Card to another 32GB SD Card which was then used on another Raspberry Pi 3 B+ board.

The clone was copied perfectly, and the other board was able to boot without problems.

However, I was thinking if there's a way to copy and backup the SD Card entirely as an image that balenaEtcher can use to write onto an SD Card? My general plan is that I'd back up SD Card in my Mac laptop as an image from time to time, and then when the need arises, I'll get use balenaEtcher to write that backup into a fresh SD Card.

I have done research and I have come across some guides that recommend using DiskUtil on the Terminal, however, those guides are pretty old and when I use diskutil list with my SD Card attached, my Mac can't properly identify the SD Card's Type and Name.

This was the most recent guide I saw. However it only runs on Windows and it will be overkill if I have to install VM or Bootcamp just to backup an SD Card.

Has anyone have an updated fool proof way of cloning a Raspbian Stretch SD Card?

Razgriz
  • 175
  • 1
  • 1
  • 7
  • does etcher have a "read" instead of "write" option? use that - oh, wait, you dont' want to use etcher to read – Jaromanda X Jan 21 '19 at 02:46
  • Next time you install stuff on the Pi create a script to do the install. That way you can easily re-install to a new sd card. – CoderMike Jan 21 '19 at 07:20
  • @CoderMike Yeah only except that I don't want to wait 4-6 hours. It would be the best option to back up my card and then have balenaEtcher do it for me in under an hour total. – Razgriz Jan 21 '19 at 07:59
  • see https://github.com/scruss/RonR-RaspberryPi-image-utils/ for a promising approach – Wolfgang Fahl Oct 19 '19 at 09:51

1 Answers1

3

See https://raspberrypi.stackexchange.com/a/72047/8697 which lists the script I use to backup my Pi on the Mac. This includes checks to prevent accidentally overwriting the wrong thing (I learnt the hard way).

The output file can be used as input to Etcher to clone/restore the card.

This, like most such using dd, suffers from the limitation that it can only restore to the same (or larger) SD Card. There are tools to shrink an image, but these only run under Linux e.g PiShrink although I have never used this, and use the tools manually if I need to modify an image.

I normally use this to make security backups, and it is useful to restore after a disaster.

I use SD Copier to actually clone cards - this is much more flexible i.e. can clone to any size card, but can be slower.

Milliways
  • 59,890
  • 31
  • 101
  • 209
  • So I have to save this script as an sh file and execute it? Correct? – Razgriz Jan 23 '19 at 01:08
  • 1
    @Razgriz Yes. You may want to customise OUTDIR and BACKUPNAME. – Milliways Jan 23 '19 at 01:12
  • Just a note. The script doesn't create the OUTDIR if it doesn't exist yet. So remember to create those directories prior. I'm a bit lazy right now to try and add the folder creation if it doesn't exist to the current script. – Razgriz Jan 23 '19 at 01:18
  • Neither the zipped nor the tar file can be used with etcher. Also the script does not work properly (see comment on stackexchange site) – Wolfgang Fahl Oct 19 '19 at 09:52