I would like to backup the entire content of my Raspberry Pi SD Card on linux PC. I have found online many tutorials that suggest to use dd to perform the operation. However my SD Cards have a wide free space that doesn't require to be saved on backup, that is why I am searching for an efficient alternative to dd that would not backup free space.

Do you have any idea of such alternative software that could do this ?

Thank you in advance.

Edit : When I say I want to perform a backup, I mean I want to make a copy of the entire OS installed in the SD Card plus personnal data installed on. When I restore the backup on another SD Card, I should get a clone of the initial SD Card. Furthermore, the backup should be done with the Raspberry shutdown and the SD Card plugged in my PC.

  • Define "backup". This means different things to different people. Also try reading the hundreds of posts on this site. – Milliways Jul 13 '17 at 7:48

There are at least two options to create bootable mSD clones, depending on whether you prefer a UI or the terminal:

  1. pi clone which gets installed alongside with the Pixel desktop.
  2. the rpi-clone script from https://github.com/billw2/rpi-clone, which does roughly the same job, but without any UI. Clone the GitHub repository, and chmod u+x rpic-clone/rpi-clone. Then ...
    • run sudo rpi-clone/rpi-clone -f sda the first time; this creates the necessary partitions and does a full rsync to ensure that you get a workable booting copy.
    • subsequent delta updates: sudo rpi-clone/rpi-clone sda.

Replace sda with your particular SD card reader/writer.

I'm solely using the rpi-clone script for many months now and I never had any issues. The only caveat: don't do a delta update to an mSD with an existing, different OS setup. Just use the -f option to ensure that you get a working clone in this case.

To slightly restate your problem, i.e. to make a minimum sized backup which can be restored to a SD Card the following script is one I use. This is for macOS (Unix) however minor changes will work on Linux. (Most of the extra code is PROTECTION to ensure the correct image is used.)

The Foundation Documentation has similar code.

#!/bin/bash
# script to backup Pi SD card
# 2017-06-05
# DSK='disk4'   # manual set disk
OUTDIR=~/temp/Pi
# Find disk with Linux partition (works for Raspbian)
# Modified for PINN/NOOBS
export DSK=`diskutil list | grep "Linux" | sed 's/.*\(disk[0-9]\).*/\1/' | uniq`
if [ $DSK ]; then
    echo $DSK
    echo $OUTDIR
else
    echo "Disk not found"
    exit
fi

diskutil unmountDisk /dev/$DSK
echo please wait - This takes some time
echo Ctl+T to show progress!
time sudo dd if=/dev/r$DSK bs=4m | gzip -9 > $OUTDIR/Piback.img.gz

#rename to current date
echo compressing completed - now renaming
mv -n $OUTDIR/Piback.img.gz $OUTDIR/Piback`date +%Y%m%d`.img.gz

You seem to want to avoid dd, which neither of these does. It depends WHY you want to avoid dd; the only disadvantage is that all data is copied, but compression means it doesn't need to be stored.

It is possible to make a new image of smaller size. This is somewhat more complex, and I know of no existing procedure. The various clone utilities can copy to smaller cards, but could be adapted to store to an image.

Since I'm not sure if it's what you're looking for, I was hoping to make this a comment instead of an answer but don't have enough (points?), anyways I've been taking the sd card out of pi putting it in a usb card reader/writer, then using win32diskimager to create an image from it.

raspiBackup is able to save only the used space even if you use a dd backup. Just read FAQ #16

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.