How do i create a full backup image for RPi Zero


I have a system which is running with all the services and configuration i want, I want to create a image in .img.gz format so that i can directly flash this image to another SD card, is it possible? If yes then how do i do that.

Thanks @frollic,

I have mmcblk0 mmcblk0p1 mmcblk0p2 which backup am i supposed to take?

for the whole card, mmcblk0.

okay thanks

My total disk consumption was around 350MB but the image is more that 500MB and still not done is this normal? or is there any compression technique that i need to follow?

command i used dd if=/dev/mmcblk0 | gzip > /backup/8-15.img.gz

you're not making a file system backup, you're backing up the whole mem card,
and if you're using squashfs you're actually compressing a compressed file system,
which will probably end up being bigger than the file system itself.

if you used the gzip example, the remaining part of the SD card should be zeroes,
unless you only did a quick format, not wiping the data, then the content might be
some random hard to compress gibberish.

you could add -9 to gzip, for max compression, but it'll slow down the dd process.

I assume /backup isn't a folder on the SD card you're backing up ? :wink:

What i understood: in this case image size will be the entire SD card size?

it is :frowning:

if dd:ed without gzip, yes, less with the compression.

but then it's dd if=/dev/mmcblk0 of=/backup/8-15.img

then you're backing up the backup file ...:smiley:

Thought so when you asked. So, i must be using a external disk for this correct?

this means output file?

something that isn't the same media, samba share, NFS, USB flash drive, whatever you've got.

yes, if= is input, of= is output.

okay thank you

it is also quite helpful, to have file-based reinstall helpers:

the has the extra option, to create custom firmware images with additional packages, based on a package name list given by you. I particularly like that, as such a custom image can then contains USB LAN adapter drivers out of the box (which is incredibly helpful on the Zero, which has no built in NIC). If you save the list as well, you can reuse it.

If you additionall backup and restore the OpenWRT config folder with LuCi, you have a more flexible set pf install files that can be mostly be reused with future OpenWRT versions as well. And you can also keep backups of different configs.

problem is, it'd kill his non standard partition table, unless the extra data he has, is located on an exroot partition.

Hi @frollic,

I attached USB drive

[ 1794.578964] Indeed it is in host mode hprt0 = 00021501
[ 1794.828954] usb 1-1: new high-speed USB device number 8 using dwc_otg
[ 1794.831984] Indeed it is in host mode hprt0 = 00001101
[ 1795.070131] usb 1-1: New USB device found, idVendor=14cd, idProduct=1212, bcdDevice= 1.00
[ 1795.074658] usb 1-1: New USB device strings: Mfr=1, Product=3, SerialNumber=2
[ 1795.077091] usb 1-1: Product: Mass Storage Device
[ 1795.079588] usb 1-1: Manufacturer: Generic
[ 1795.081988] usb 1-1: SerialNumber: 121220160204
[ 1795.085403] usb-storage 1-1:1.0: USB Mass Storage device detected
[ 1795.120591] scsi host0: usb-storage 1-1:1.0
[ 1796.159826] scsi 0:0:0:0: Direct-Access     Mass     Storage Device   1.00 PQ: 0 ANSI: 0 CCS
[ 1796.396678] sd 0:0:0:0: [sda] 62333952 512-byte logical blocks: (31.9 GB/29.7 GiB)
[ 1796.403412] sd 0:0:0:0: [sda] Write Protect is off
[ 1796.405515] sd 0:0:0:0: [sda] Mode Sense: 03 00 00 00
[ 1796.428251] sd 0:0:0:0: [sda] No Caching mode page found
[ 1796.430360] sd 0:0:0:0: [sda] Assuming drive cache: write through
[ 1796.445281]  sda: sda1
[ 1796.455872] sd 0:0:0:0: [sda] Attached SCSI removable disk

how do i write to this? directly to /dev/sda?

ls /dev/sd*
/dev/sda   /dev/sda1

Upadte: I did temporary mount using mkdir /tmp/MyDrive; mount /dev/sda1 /tmp/MyDrive

sda is the whole drive, just like mmcblk0, sda1 is the 1st (and perhaps only) partition on it.

now just do dd if=/dev/mmcblk0 | bzip2 --best > /tmp/MyDrive/SD-backup.bz2, or similar.

Yes i did using dd if=/dev/mmcblk0 | gzip -9 > /tmp/MyDrive/8-16.img.gz and it works, thank you so much for the help.

1 Like

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