SD backup with Win32 Disk Imager

I wrote instructions for backing up my SD card with Win32 Disk Imager because I always ended up stumbling somewhere in the process. This is my procedure. It seems unnecessarily complicated, but since Win32 Disk Manager can’t see disks, only partitions, there seems to be no way around erasing the partitions and creating a new one before write the image. Any improvements?

  1. Stop OpenHab and Rpi
  2. Take out micro SD and put it in adapter and put it into PC reader
  3. Open Win32 Disk Imager
  4. In combo to right of image file field, select first partition on card. It isn’t clever enough to show all the partitions together
  5. Open image backup directory
  6. Copy path and enter full path to new image file in Image file edit box (e.g.: S:\Backup\Openhab_backups\SD card images\OpenHab SD card image 2020-10-10.img)
  7. Ensure no folder windows or other open processes are accessing the card. Click Read
  8. When the read finishes, eject the card and put it back in the Rpi and restart it
  9. Close Win32 Disk Imager
  10. Open Computer Management and delete both partitions from the SD card (typically I: and O:).
  11. Format the card to one single partition (7.51 GB)
  12. Open Win32 Disk Imager and paste in the path to the img file created earlier in the Image File edit box
  13. Select the SD card partition in the combo and click Write

Well. While it may work, your approach has some issues.
You need to take OH down for some time, you need physical access to play (s)disk jockey, need a Windows machine and you have no backup management/reporting, just to name some major issues with this method.
For openHAB running on RPi, there is a different, recommended approach:
openHABian includes a comprehensive backup solution that takes care of all of these points and more.
We also recently added menu options to clone the internal SD card on the fly in operations (i.e. the same what your solution does, just online) and we even added a sync mechanism to automatically keep it up to date.

PS: and even if you didn’t use the openHABian image to install your RPi, you can still install it on top of your running system (although I’d take the chance to start with a well-defined starting point, i.e. reinstall).

I’ll certainly check out the on-the-fly backup, which sounds like the best approach.

From my reading, it sounds as if the on-the-fly backup method requires a physical SD card. Is this correct? You can’t create card images?

The openHABian builtin function requires that, yes. It’s what the whole point is about:
to have the spare ready at any time.
You can create images using the UNIX commandline, but taking images is a form of backup, and for that purpose better use Amanda which is also there. Yes that works on-the-fly, too.

OK, perhaps one day I’ll have the patience to look at Amanda.

In the meantime, can anyone answer my original question: is there any way to avoid deleting the partitions on the SD card before restoring the image?

Well don’t get this wrong please but if you had invested the time it took to figure out your imaging procedure and write this thread into Amanda instead you would well be done by now.
And have a better solution to your problem.

I think you’re wrong there. Amanda is clearly another rabbit hole, and I have limited time and patience to go down rabbit holes. The SD card backup procedure is annoying, but it’s not all that time consuming to work out.

There are clearly a lot of people here with the time and inclination to spend hours messing around with this stuff. I can do that, sometimes. But in small doses.

A pretty questionable claim given you haven’t tried that. It’s a matter of minutes for the default setup.

I’ve read the documentation. Absolutely everything in OpenHab is a rabbit hole, and I have a life. I have other things to do.

Aha. Guess what: so do we. I understand my time is wasted here.

Certainly true. In the meantime, perhaps someone can answer my question.

For those who are interested, I’ve found a tool that will directly write an image to the SD card without requiring you to delete the partitions and format first: balena-etcher. However, since it doesn’t read images, you still need to use another tool to make the image. So my revised method is:

  1. Stop OpenHab and Rpi
  2. Take out micro SD and put it in adapter and put it into PC reader
  3. Open Win32 Disk Imager
  4. In combo to right of image file field, select first partition on card (typically I:). It isn’t clever enough to show all the partitions together
  5. Open image backup directory
  6. Copy path and enter full path to new image file in Image file edit box
  7. Select “Read only allocated partitions” so that the little bit of free space at the end of the card is excluded from the image.
  8. Ensure no folder windows are opened showing the card. Click Read
  9. When the read finishes, eject the card and put it back in the Rpi and restart it
  10. Close Win32 Disk Imager
  11. Put the target card in the card reader.
  12. Ensure that AutoPlay for removable drives is turned off. Otherwise, as soon as the new drives appear, a folder window will open and prevent the card writing software from obtaining exclusive access.
  13. Open balena etcher, select the image and target drive and click Flash.

A bit simpler than before.