I am pretty new in Linux. I am configuring my Raspberry that use Raspbian.

Before to perform some settings I want to have a backup of my entire system in the current state.

What can I do to save the entire system on a backup file (or something like it)? I want create an image of the SD card that contains my actual system state (so it have to contains the 2 used partitions and the file system).

In such a way that if I do some error I can restore my system.

To write Raspbian on the SD card I used the Linux dd command; can I do the same operation in the opposite direction (copy the actual state of my SD Card on a backup file)? If yes, what have I to do?

  • Have you looked at Win32DiskImager? It makes an exact clone of your card to a .img file in Windows.
    – SDsolar
    May 3, 2017 at 3:53

3 Answers 3


I faced a similar issue and therefore wrote a tool just for my private use. I decided to call it raspiBackup and made it open source when I thought it may be valuable for the community also. It took me a serious amount of time to make it robust, add parameter checking and error handling so it's usable by the community. Feel free to report issues or create feature requests on GitHub.

Main features are:

  1. Unattended backup of a running Raspberry Pi (Pi backups itself)
  2. Other similar SoCs are supported (Banana Pi, Ondroid, Beagle Board, Cubieboard, ...)
  3. Raspbian, Arch, Ubuntu, Volumio, NOOBs ... Raspberry Pi 3 running without SD card (booted from USB) is supported
  4. The partitionoriented backupmode backups a variable number of partitions of the SD card and thus can save NOOBs images and images with more than 2 partitions
  5. Backup and restore is independent of the operating system (Linux, Windows or Mac) used to access the Raspberry Pi
  6. Windows or Mac user just use the Raspberry to restore their backup
  7. Windows user can restore dd backups with win32diskimager
  8. Linux user can use their Linux system or the Raspberry to restore the backup
  9. Plugins allow to extend the script capabilities with custom code
  10. Various backup targets, for example External USB stick External USB disk Synology drives cifs/samba mounted network drive nfs mounted network drive sshfs mounted network drive webdav network drive Mounted ftp server In general every device which can be mounted on LInux
  11. Simple restore of the backup
  12. An external root filesystem on disk or USB stick will be saved with in the normal backup mode if tar or rsync backup is used
  13. Can be used to clone Raspberry Pi
  14. Simple installation. A configuration wizzard helps to configure the most important parameters.
  15. Messages in English and German
  16. Lots of invocation parameters to customize the backup process
  17. dd, tar and rsync backup possible (-t option). rsync uses hardlinks if an ext3/ext4 partition is used
  18. dd and tar can be zipped also to reduce the backup size (-z option)
  19. dd backup can be enabled to save only the space used by the partitions. That way a 32GB SD card with a 8GB partition will only need 8GB for backup
  20. Boot partition backups are saved with hardlinks to save backup space if enabled with an option
  21. Different backup types can be mixed per system (e.g. day backup uses rsync, weekly backup uses dd)
  22. Automatic stop and start of running services before and after the backup (-a and -o option)
  23. A Sample script helps to easily add additional activities to be executed before and after the backup. E.g. mount and unmount of the backup device
  24. Number of backups to keep is configurable (-k option)
  25. If the target SD card is smaller or larger than the original SD card the second root partition will be adjusted accordingly
  26. eMail is sent to report the backup progress and result (-e option)
  27. rsync uses hardlinks if possible to reduce the backup size
  28. Supported eMail programs: mailx/mail, sendEmail and ssmtp (-s option)
  29. Unsupported eMail clients can be used via the eMailPlugin
  30. Automatic notification if there is a newer version of raspiBackup available (-n option)
  31. Simple update of raspiBackup to the latest version (-U option)
  32. Simple restore of a previous version of raspiBackup (-V option)
  33. Arbitrary directories and files can be excluded from the backup (-u option)
  34. Multiple Raspberries can save their backup at the same place
  35. Support of Volumio
  • Just posting a link isn't the way answers should be done on this site. A comment is a better place.
    – Ingo
    Jul 12, 2018 at 11:13
  • A lot of people donated bounties when I suggested this tool. You're the only one who downvotes. What's the difference whether someone just suggests to use win32diskimager and I suggest to use raspiBackup?
    – framp
    Jul 12, 2018 at 20:13
  • 1
    @Ingo I believe framp has done a very good job now, future readers will be able to decide if the tool will fit their requirements. Please consider removing your downvote!
    – linusg
    Jul 12, 2018 at 22:35
  • +1. I have seen a lot of one liner answers that are down voted
    – Ingo
    Jul 12, 2018 at 23:54

Yes you can do that. I use it to deploy a setup to multiple Pis, without have to reinstall an setup every Pi individually. When using dd I think I just swapped the if and of paths. So something like sudo dd if=/dev/diskn of=path_of_your_image.img bs=1m

  • 1
    it's not generally recommended to deploy multiple systems from the same image, because there are some parts that's supposed to be unique, like certificates and other crypto stuff. having several "twins" on the same network might lead to a very interesting problems.
    – lenik
    Jun 3, 2014 at 22:07
  • The certificate is either a problem or a feature. But use with caution. Having multiple Pis with the same image, on the same network, hasn't caused any problems for me. All Pis have a different MAC address, no matter what image you run.
    – Gerben
    Jun 4, 2014 at 17:29

Unmount the card, then try:

sudo dd if=/dev/sdcardlocation of=backupimage.img.

Replace sdcardlocation with the location of your SD card.

You could swap .img with .dmg or .iso.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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