-1

I have tried several methods on my Mac to backup and recover an image of the SDs on my raspis. The only method that has consistently proved to work for me is the "dd" from Mac terminal. The inherent problem with this approach is that if you fail to write the correct disk address (/dev/rdsknn) you can wipe out the hard disk from the Mac or some of the external mounted drives.

Other methods (Balena Etcher, etc...) have not worked mostly because of errors related with the capacity of the SD card.

Does anybody know some effective method (alternative to dd) to backup and restore a SD card image on a Mac that do not put at risk the integrity of the drives in the Mac?

Vadim
  • 565
  • 3
  • 12
Joan I
  • 9
  • 4
  • Doesn't seem to be about Raspberry Pi. Wrong community – Vadim Apr 18 '23 at 07:36
  • ?? It is about backing up the SDs of a Raspberry. It is one of the first things to do for anyone playing with Raspis – Joan I Apr 18 '23 at 14:20
  • Yes it is essential, however to me sounds rather like "how to backup an SD card..?" which is generic independent if it is Pi's SD or any else. Unless you see a critical difference, and will be willing to point it out in your question – Vadim Apr 18 '23 at 15:11
  • I know how to copy a SD card to another one, but this kind of copy cannot be used for backing up raspi SDs. There are quite a lot of apps intended for doing this that when executed give errors (BalenaEtcher, PiBaker,...). The question is so, inherent to Raspis – Joan I Apr 18 '23 at 16:00
  • Perhaps you can point it out in your question, especially if you know what is making it different from simple copy – Vadim Apr 19 '23 at 07:13
  • If you look in the forums you will see that to copy the SD of a Raspi (working RaspiOS + files) cannot be done like copying photos on a SD. It requires a very different approach otherwise all the replies that follows would not make sense. You have a lot of badges on this forum. You should know it – Joan I Apr 19 '23 at 10:14
  • In my opinion, It still would worth mentioning it in your question, so you may want to add a line about it. In any case it is up to you. – Vadim Apr 26 '23 at 11:11

2 Answers2

0

See https://raspberrypi.stackexchange.com/a/29085/8697

This is a script I used to use which performs a safety check.

dd is not a particularly good backup strategy; it is slow and can only restore to an identical (or larger card).

I use an incremental backup approach.

Milliways
  • 59,890
  • 31
  • 101
  • 209
  • Milliways, this is a very well crafted bash script. It is a very good option to avoid errors and avoid fatal accidents. Thanks for sharing – Joan I Apr 18 '23 at 15:54
0

dd isn't a good backup method for backing up a live system, but it sounds like you may be trying to back up an SD card that you've removed from the system. I don't know if you have a special reason for preferring to do back ups on SD cards after they've been removed from the RPi... To my way of thinking, a live system backup would always be preferable - but that's me :P

As a suggestion, I'd recommend you consider doing live system backups using the image-backup utility instead of offline backups:

  • creates backup as an image file which can be mounted on RPi (useful following upgrading to a new version of the OS), and simplifies system restoration from backup.

  • it's fast (3-5 minutes for a complete system backup on RPi 4B to a network drive).

  • compact backup (does not waste space storing unused portions of SD card)

  • existing image files may be updated in a fraction of the time required for a complete system backup; e.g. following an apt upgrade or other system revisions

This last feature in particular simplifies backup logistics; I've written a small script to automate updating my backups to reflect the latest configuration.

But as to your question:

The hdiutil CLI tool is available in macOS for creating and manipulating image files, but AFAIK it isn't capable of working with an ext4 filesystem. But see man hdiutil for the official word on that, or the online docs for the GUI version - Disk Utility.

Seamus
  • 21,900
  • 3
  • 33
  • 70
  • The reason for doing an off-line backup is that I was not aware of the possibilities of backing up a live system. Following your post I will definitely have a look at this option. Thanks very much for your help – Joan I Apr 18 '23 at 15:57
  • I have bought a SD card reader with a microusb cable allowing to plug it in a RaspiZero without interfering with the power microusb cable, and I have done a live backup with the built in SD Card Copier in the raspi as you suggested. Everything has gone smoothly (even being the 2 SDs of different capacity). I have shutdown the raspi, switched the SDs and the raspi has booted without problems. Definitely among all the backup procedures I have tested so far, this is the simplest and safest approach. I guess that this is the backup procedure that I will use in the future. Thanks very much, Seamus. – Joan I Apr 20 '23 at 14:49
  • @JoanI : Glad to hear you found it useful. Don't forget to vote :) – Seamus Apr 20 '23 at 15:48