News How to Back Up Your Raspberry Pi as a Disk Image

There's a one-step way to create the compressed backup image without requiring an intermediate file.

cd /media/pi/pibkp
dd if=/dev/mmcblk0 | gzip -c - > mysys.img.gz

I did have a problem with the NTFS filesystem on the USB drive being read-only. Fixed it with:

sudo apt-get remove ntfsprogs
sudo apt-get install ntfs-3g
reboot
 
Last edited:
"If your drive isn’t mounted, try rebooting with the USB drive connected or you can mount it manually by typing sudo mkdir /dev/mysub to create a directory and sudo mount /dev/sda1 /dev/myusb to mount it." One of the /dev/myusb or /dev/mysub needs correction.
 
I use an adapter for this: https://www.amazon.com/usb-micro-sd-adapter/s?k=usb+to+micro+sd+adapter
Get one of these from any shop. Shutdown your RPI, take out the microSD-card. Plug it into adapter and plug adapter to PC.
I make backup image in Linux because why wouldn't I have Linux installed.

To find out which device it is on your system, run lsblk, blkid or similar in terminal. You might need 'sudo' before the command. 'sudo blkid', 'sudo lsblk', 'sudo fdisk -l'.
Another, graphical way, is using Gnome-disk-utility. It's also easy to mount/automount your NTFS partitions if you want. In case you want to move the backup to your Windows partitions. Always save a backup in more than 1 place. You never know when you have to wipe OSes or partitions or the drive just fails.

It's 1 command: sudo dd bs=4M if=/dev/sdf of=/home/<replace with your username>/rpi.img

if = inputfile. In this case a /dev which is a Device. Sdf is the specific device, in this case my USB-adapter. Don't add any number after sdf. You want the whole device imaged.
of = outputfile. Where you want the image saved. Up to you where you put it.

Here is a guide how to automount your NTFS-partitions: https://www.freecodecamp.org/news/automount-a-storage-partition-on-startup-in-linux/
Or any partition/device really. It's the exact same procedure. And it is very easy.

If you are on Manjaro like me (or any Arch-derivative I imagine):
'sudo pacman -Sy'
To update repository

'sudo pacman -S gnome-disk-utility '
To install Disks-utility. If you open the utility via Start-menu, it will be called 'Disks'. Works on any Desktop Environment. I am running KDE Plasma. So don't think you have to have Gnome installed or running.

You can also do this graphically, as in the guide. To me, it just takes too long. Faster via terminal.

So now you have the image of your RPI. Copy it to a couple places so you'll always have it.


To image it back to an SD-card, use something like Balena Etcher. You can also use DD but of course reversed. Input file is the image. Outputfile is your device. DD has no failsafes so I would suggest Balena Etcher, so you don't overwrite your OS or anything.
It's those 3 steps, as pictured on the website. Select image, select drive, flash. It is that simple. If you are using an adapter like me, it should be a Mass Storage Device with the size of your SD-card, when you go and select drive.
 
Last edited:
I looked at this option and the one mentioned by aixylinux above, and a number of other options. The simplest and most efficient tool I saw was mentioned here:
https://raspberrypi.stackexchange.c...remotely-create-a-shrunk-backup-image-of-a-ra

The one posted here isn't as efficient/requires more fiddling with to get to work, using "dd" method per aixylinux is going to result in a file the size of your drive (including empty space). https://github.com/seamusdemora/RonR-RPi-image-utils is the best of both worlds, and has easy incremental backup