Downgrade SD card & Proper Backups of PiHole

Hello,
At the time of my pihole setup I only had 32GB SD cards. This size is a little excessive. When I make my pihole backups I use Win32DiskImager to make a 1:1 block copy of the card, which is 32GB. Quite a large size for a backup.

I was looking for help or suggestions on the following:

  1. Being that I have 1:1 block copies of my pihole, there is no way to use this block copy to downgrade to say a 8GB or 16GB sd card.
  2. Is there a better method of backing up PiHole that I am unaware of, that way if there is ever a failure I can use a SDcard of any size?

Thank you

If you haven't used up the full size of the 32G card then most of the card is just 0s. Doing an exact image will give you an image packed with nothing to fill out the size. You really just want the data to be backed up.

There's a ton of posts on various forums about shrinking images, Cloning pi sd card to a smaller one 16gb to 4gb - Raspberry Pi Forums is a script to handle it.

My personal opinion, with the cost of SDCards there's no real reason to do any of this, 32G are dirt cheap and not really any more expensive than 8Gs.

I figured as much that it would be mostly 0s
I keep a 1:1 image in case the SD card ever wants to quit one day. I do quarterly or semi-annually backups by shutting down the pihole, pulling the card, and imaging on Windows. Sucks for the downtime but hey what can you do.

I will look into that shrinking topic.
I was wanting to go to say a 16GB card only because 1:1 backups of 32GB cards take a while and of course the space as well.
The application will not allow me to write a 32GB 1:1 image to any card smaller then 32GB.

I will have to ponder my strategy moving forward, or maybe leave it as is.
doing a 1:1 backup is the best fail-safe?

Only if you have additional 32G cards with the same, or higher, sector count. 32G is not always exactly the same number of sectors, different manufacturers, different cards, different quality controls all affect that number. If you have a 1:1 image from a card that has fewer bad blocks than the card you want to restore to, you will not succeed. win32diskimager will halt and tell you the image is bigger than the card.

https://www.raspberrypi.org/forums/viewtopic.php?t=147371

1 Like

I use a script (based on rsync) to built a (custom size) image from within the active OS and save it locally (either on a USB drive) or in a non backup folder (like /media/).

File can be restored with win32img and then the installed FS expanded to the full size of the card.

This prevents the "sector count" lottery one plays with same "size" cards.

For instance, active card with active OS is 32Gb but installed OS and dependencies take up only 3Gb.

Script can build the running image at 3.1GB, and that can be restored on any card that would fit itm regardless of sectors)... Then, expanded via raspi-config

Here it is:

(make sure to change NSHARE="/YOUR/PATH/" to something like /media/ as that folder is not included in the backup)

When prompted for the size, enter 0 as the value (if you don't want to save the image file with the full SD size) and you will be prompted to enter a (smaller) value for the image.

image

2 Likes

Perhaps not. A larger capacity card has more available locations for writes, which minimizes the number of writes to each individual location on the card, and thus a longer SD card life. I would keep using the 32 GB cards. They are a few $$ US more than a 16 GB card. Buy 32 GB cards to make backups as well - write the existing card to an identical card as a backup.

I only use 32 GB SD cards, for both the running OS and the backup. SanDisk Ultra seem to be a good quality card at a reasonable price. I have about 15 or so of these.

Makes sense, I suppose I only knew the 1:1 method to make a block copy backup. Was looking to shink the size of backups or even make backups without having to take pihole offline (backup takes 60min to read) via Win32DiskImager.
Perhaps I have some learning to do (as stated above). Gotta brush up on my bash skills and make an instruction set to backup PiHole accordingly

You can do this with the Pi running using Linux utilities. In particular, dd.

I have been using Apple PiBaker for a while with no issues at all. Resultant image file comes out smaller than original image. See if this helps anyone -

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.