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?
Stop OpenHab and Rpi
Take out micro SD and put it in adapter and put it into PC reader
Open Win32 Disk Imager
In combo to right of image file field, select first partition on card. It isn’t clever enough to show all the partitions together
Open image backup directory
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)
Ensure no folder windows or other open processes are accessing the card. Click Read
When the read finishes, eject the card and put it back in the Rpi and restart it
Close Win32 Disk Imager
Open Computer Management and delete both partitions from the SD card (typically I: and O:).
Format the card to one single partition (7.51 GB)
Open Win32 Disk Imager and paste in the path to the img file created earlier in the Image File edit box
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).
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.
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.
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:
Stop OpenHab and Rpi
Take out micro SD and put it in adapter and put it into PC reader
Open Win32 Disk Imager
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
Open image backup directory
Copy path and enter full path to new image file in Image file edit box
Select “Read only allocated partitions” so that the little bit of free space at the end of the card is excluded from the image.
Ensure no folder windows are opened showing the card. Click Read
When the read finishes, eject the card and put it back in the Rpi and restart it
Close Win32 Disk Imager
Put the target card in the card reader.
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.
Open balena etcher, select the image and target drive and click Flash.