Colourful Norwich skyline illustration

Michael Sage

IT, Digital & Culture

Backing up a Pi (with USB HDD)

Raspberry Pi Logo

Pi Backup

Time for another text based pi article.. sorry!

Attach the USB disk to the pi.

Next download pi shrink

sudo chmod +x
sudo mv /usr/local/bin

Next check for the correct paths


Now run a dd copy to create the image

sudo dd if=/dev/mmcblk0 of=[mount point]/myimg.img bs=1M

Finally shrink the image

sudo -z myimg.img

You now have a size optimized image that you can restore using the “official” pi image writer software. You can stick this in a cron job to create a regular image backup of any pi.


If you are cloning to test or deploy into another Pi, you will need to delete the VNC config or you will get a “cloned” error in the VNC client and it could stop working. Luckily it’s simple to fix, on the cloned machine do the following:

sudo systemctl stop vncserver-x11-serviced
sudo rm -rf /root/.vnc
sudo systemctl start vncserver-x11-serviced