User Rating: 4 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Inactive
 

raspiBackup helps to create backups of a running Raspberry with no shutdown or manual intervention which means your can save or clone your SD card during normal operation. An exported root partition will be saved too. Important services will be stopped just before starting the backup and are started again when the backup finished. Any device which can be mounted on Linux can be used as backupspace (USB disk, USB stick, nfs, samba, sshfs, ...). The backup image can be created with dd, tar or rsync using hardlinks. Restore is possible on Windows or Linux. Source Raspbian may have been installed on SD card only or the boot partition may be on SD card and the root partition on an external USB device like USB SSD or USB stick. Raspbian installed on an USB device only using USB boot mode is also supported

 

 

 

Please read first: Supported hard- and software

 

On facebook there exists a group for raspiBackup where news and other insights about raspiBackup are published.

Any hot updates will be published on twitter #raspiBackup.

On Youtube there exists a channel for raspiBackup with various videos (Installation, Introduction, ...).

Everybody who enjoys raspiBackup and want to honor the work and support can donate. See details on this page.

raspiBackup is written in bash and is published on github .

 

Contacts

  • Click FB f Logo blue 29 to ask questions or report issues on Github. My preferred contact channel. That way I'm able to track questions or problem reports and you will get update notifications.
  • Click FB f Logo blue 29 to read news and background information in English about raspiBackup or ask questions. Please report issues on github..
  • Click Youtube to view Youtube videos about raspiBackup
  • Click Twitter f Logo blue 29 to follow raspiBackup on Twitter
  • Click Comment to ask a question in a comment. Please report issues on github.

 

Support, Donations and Sponsoring

  • Click Donate if you want to know how to donate if you like raspiBackup.
  • Click to become a github sponsor for raspiBackup.

 

Note: Any other contact pathes like eMails which unfortunately are used heavily are silently ignored!

 

Where to go next?

If you want to evaluate and test raspiBackup read this quickstart page and install raspiBackup in 5 minutes to create a backup very quickly.

raspiBackup has a lot of features and that's why there exists a lot of documentation. If you want to get a quick overview about the capabilities of raspiBackup just read the summary. If you want to know about all features and supported environments in detail continue with the feature chapter. If you want to install raspiBackup just follow the installation description. Don't forget to read the FAQ page. The invocation synatx is described here. All invocation options of raspiBackup are listed alphabetically and theme sorted. How to restore a backup is described on this page

If you want to extend raspiBackup read the extensability section. If you get error messages from raspiBackup read this section. For pros and cons of the backup types click here. There you find also a decision tree to find the right backup mode. For details about the two backup modes of raspiBackup read here. A list of bugfixes and enhancements in the old and new version is available here. If you want to use a Synology for your backups read this page. Development of raspiBackup is and will be driven by users of raspiBackup.

For other topics see the following index.

 

Erstellt dd backups

  1. Summary
  2. Features
  3. High level overview
  4. Installation
  5. Invocation syntax and options
  6. Extensabilitiy
  7. Restore
  8. Errormessages and troubleshooting
  9. Backup types and decision tree
  10. Snapshots
  11. Backupspace directory structure
  12. Disclaimer
  13. Updatestrategy
  14. Languages
  15. Regressiontests
  16. Versionhistory
  17. Use Synology as backupspace
  18. Additional pages about raspiBackupFAQ
  19. Useful links related to backup
  20. Version history
  21. Credits
  22. Donations
  23. Statistics

 

Summary

raspiBackup helps to create a backup of a Raspberry Pi on a periodic base. The backup is created by the Raspberry itself and stored on an external storage device like an usb stick, an usb disk, nfs server, smbfs/cifs/samba drive, sshfs, davfs/webdav (Cloud)davfs/webdav (Cloud) etc. (See also How to access external data via smb, nfs, ssh, ftp and dafvs on Raspberry). A synology can also get the backups.

Of course restore of the backup is also handled by raspiBackup.

All running services should be stopped before the backup is started and restarted when the backup finished to get a consistent backup. Commands to start and stop the services can be passed to raspiBackup either via options or a sample wrapper script can be used, which allows to execute much more program controlled activities before and after the backup. Automount and unmount of the backup space is already coded in the sample wrapper script.

The normal backupmode will save both SD card partitions mmcblk0p1 and mmcblk0p2. If the root partition was moved to an external partition (USB stick, USB disk, ...) this external root partition will be saved instead of mmcblk0p2.

The maximum number of backups is configurable and only the latest backups are kept. Possible backup methods are dd backup, tar backup, (both can be zipped also) and rsync backup .

Activation of raspiBackup is simple. Test the backup and finally add the script call in your crontab of your Raspberry Pi. Now you get an eMail every time a backup was created and will be informed about the backup result. Messages written by raspiBackup are in English and German.

 

Features

  • Unattended backup of a running Raspberry PI (Pi backups itself)
  • Raspberry3 and beyond running without SD card (USB boot mode) are supported
  • 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. For an USB boot mode system any number of external  partitions can be saved starting with Release 0.6.6.
  • Backup and restore is independent of the operating system (Linux, Windows or Mac) used to access the Raspberry Pi
  • Windows or Mac user just use the Raspberry to restore their backup
  • Windows user can restore dd backups with win32diskimager
  • Linux user can use their Linux system or the Raspberry to restore the backup
  • Plugins allow to extend the script capabilities with custom code
  • Various backup targets, for example
    • External USB stick
    • External USB disk
    • Synology drivesaus
    • 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
  • Simple restore of the backup and update of /etc/fstab and /boot/cmdline.txt to reflect the new UUIDs, PARTUUIDs or LABELs so the restored system boots immediately.
  • Can be used to clone Raspberry Pi
  • Simple installation. A configuration wizzard helps to configure the most important parameters.
  • Messages in English and German
  • Lots of invocation parameters to customize the backup process
  • dd, tar and rsync backup possible (-t option). rsync uses hardlinks if an ext3/ext4 partition is used
  • dd and tar can be zipped also to reduce the backup size (-z option)
  • pishrink can be used to shrink dd images using a wrapper script
  • 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
  • Boot partition backups are saved with hardlinks to save backup space if enabled with an option
  • Different backup types can be mixed per system (e.g. day backup uses rsync, weekly backup uses dd)
  • Automatic stop and start of running services before and after the backup (-a and -o option)
  • Automatic notification if there is a new Release available
  • 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
  • Number of backups to keep is configurable (-k option)
  • Smart recycle backup strategy can be used (keep Backups of last 7 days, last 4 weeks, last 12 months, last n years)
  • If the target SD card is smaller or larger than the original SD card the second root partition will be adjusted accordingly
  • eMail is sent to report the backup progress and result (-e option)
  • rsync uses hardlinks if possible to reduce the backup size
  • Supported eMail programs: mailx/mail, sendEmail, ssmtp and msmtp (-s option)
  • Unsupported eMail clients can be used via the eMailPlugin
  • Automatic notification if there is a newer version of raspiBackup available (-n option)
  • Simple update of raspiBackup to the latest version (-U option)
  • Simple restore of a previous version of raspiBackup (-V option)
  • Arbitrary directories and files can be excluded from the backup (-u option)
  • Multiple Raspberries can save their backup at the same place
  • Support of Volumio
  • Native language support for
    • German
    • Finnish
    • Chinese
    • French

 

 

High level overviewraspiBackupOverview

Installation

 

Fastest and standard way to install raspiBackup in 5 minutes and create a backup is explained on raspiBackup Quickstart. There you also find a description how to install raspiBackup via commandline with it's standardconfiguration. If you want to install raspiBackup manually visit this page.


  Invocationsyntax and -options

See this page
 

Extensions

Following options exist to extend the backup script with custom code:

1) Call a custom script which then calls the backup script and executes code before and after the backup

Following sample script is available and can be used and customized accordingly. Code which mounts and unmounts the backup partition is already included.

Prerequisite is to have the mountpoint already defined in /etc/fstab and copy the script in the following directory.

sudo mv raspiBackupWrapper.sh /usr/local/bin
sudo chmod +x /usr/local/bin/raspiBackupWrapper.sh

Now call raspiBackupWrapper.sh instead of raspiBackup.sh. Wrapper script source code is available on github and can be extended with a pull request.

2) Usage of extensionpoints to plug in your custom code

For details see here

 

Restore

To restore backups of type tar and rsync you need a Linux system. You oly need a Raspberry which runs Raspbian and an external SD Cardreader. A dd backup can also be restored with Windowstools. Follow these instructions to restore the backup

 

Errormessages and troubleshooting

It's possible raspiBackup doesn't work as expected ans writes some messages. 90% of the time it's some misconfiguration or incorrect parameters. Read the error messages carefully.THe most common error messages are explained in more detail on this page.
 
If you don't get why something goes wrong:
 
1) Start the script on the commandline and don't start it in the crontab
2) raspiBackup creates a debug log raspiBackup.log in the backup directory. If the backup fails and the backup directory will be cleaned up the debug log is saved in the home directory of the caller first. Check the debug log for error messages. In addition parameter -v can help to get further informations if errors occur in the backup tools.
3) If it's still not possible to locate the root cause of the issue please report the issue. See notes how you can report them.
 

Backup types

Every backup method has it's pros and cons. See the following list to decide which backup method is the right one for you to use. It's even possible to combine different backup types.

dd Backup creates a consistent binary backup of the SD card. The whole SD card will be read and saved. But this includes also data which didn't change compared to the last backup. In addition the SD card for restore has to have at least the size as the original SD card. There is not any partition resized accordingly. This backup method stresses the SD card and is huge. Every dd backup can be restored with win32diskimager on Windows.
ddz Backup backups the whole SD card but compresses the final image. This method stresses the Pi CPU. There is no restore possible with windisk32manager on Windows.
tar Backup backups the whole SD card but only saves only the existing data and therefore the backup is usually much smaller than the whole SD card. Therfore the backup can be restored on a smaller SD card as long it's capable to keep the saved data.
tgz Backup backups the whole SD card but only saves only the existing data and therefore the backup is usually much smaller than the whole SD card. Therfore the backup can be restored on a smaller SD card as long it's capable to keep the saved data. This method stresses the Pi CPU.
rsync Backup backups data which was changed to the last backup only. Hardlinks of the ext3/ext4 filesystem guarantees there exists a consistent backup. There is no data compression. But this allows to restore files very easy by just copying the files. First backup takes a long time but all subsequent backups are created very fast.
 
  Full backup Backuptime Backupsize
Datacompression CPU stressed
Karte stressed Single file restore Filesystem
dd  yes high big no medium high no everything, fat32 max 4GB
ddz yes high medium yes high high no everything, fat32 max 4GB
 tar yes medium  medium no medium medium yes everything, fat32 max 4GB
tgz yes medium medium yes high medium yes everything, fat32 max 4GB
rsync yes (once), no

low with hardlinks

medium without hardlinks

small with hardlinks

medium without hardlinks

no low low yes ext3/ext4

decisiontree en.dia

 

You will find more details about the backup filesystems  here.

 

Comparison of partitionorientierted backup and normal backup

 

1) Normal backup

This standard mode saves the first two paritions. (bootpartition and rootpartition) of the SD card. In addition tar and rsync backup will save an external rootpartiion i.e. a partition located on an USB Stick or USB. The dd backup can be used to save the whole SD car which can be used to save NOOBS images. If the target SD card has more space than the source SD card the second partition is extended accordingly.

2) Partitionoriented backup

Every partition or a  given number of partitions on the SD card will be saved as tar or rsync. The number of partitions is not limited. If the target SD card is larger than the source SD card the additional space will not be used. 

 

 

Backupspace directory structure (Normal backup)

every backup creates a backup directory and a subdirectory which hat following format: <hostname> and a subdirectory <hostname>-<backuptype>-<backupdatum>. If option -M is used the folder created is <hostname>-<-M parameter> and the subfolder will be <hostname>-<backuptyp>-<backupdatum>.

Examples: Raspberry has hostname raspberrypi and a backip is created on 2016/04/15 at 22:29:00 THe directory created will be raspberrypi and the subdirectory will be raspberrypi-dd-backup-20160415-222900. If option -M is used with parameter "Hello world" the directory created will be raspberrypi-Hello_world and the subdirectory will be raspberrypi-dd-backup-20160415-222900.

See the following backup directory structure I use on my backupserver which is also a Raspberry Pi. You can see that some Pis save themself on a regular base whereas others are saved only manually. 5 Pis save themself which can be seen by the different hostnames used. In addition different backup types can be saved in one backup directory.

For every Raspberry there are three or five additional files created in addition to the data backup and are needed for the restore if the backup is no dd backup.

  1. .img - Bootpartition of the SD card
  2. .mbr - Master boot record of the SD card
  3. .sfdisk - Partitionlayout of the SD card - Result of sfdisk command
  4. .blkid - (Partitionoriented backup only) - Result of blkid command
  5. .parted - - (Partitionoriented backup only) - Result of parted command

root@jessie:/mnt/backup/raspberrypi# tree -L 2
.
── raspberrypi-dd-backup-20160415-222900
    raspberrypi-dd-backup-20160415-222900.img
    ── raspiBackup.log
    ── raspiBackup.msg
├── raspberrypi-rsync-backup-20160416-094106
│   ├── backup
│   ├── bin
│   ├── boot
│   ├── boot.bak
│   ├── dev
│   ├── etc
│   ├── home
│   ├── lib
│   ├── lost+found
│   ├── media
│   ├── mnt
│   ├── opt
│   ├── proc
│   ├── raspberrypi-backup.img
│   ├── raspberrypi-backup.mbr
│   ├── raspberrypi-backup.sfdisk
   ── raspiBackup.log
   ── raspiBackup.msg
│   ├── remote
│   ├── root
│   ├── run
│   ├── sbin
│   ├── selinux
│   ├── srv
│   ├── sys
│   ├── tmp
│   ├── usr
│   └── var
── raspberrypi-tar-backup-20160415-204305
    ├── raspberrypi-backup.img
    ├── raspberrypi-backup.mbr
    ├── raspberrypi-backup.sfdisk
    ── raspberrypi-tar-backup-20160415-204305.tar
    ── raspiBackup.log
    ── raspiBackup.msg

 

Backupspace directory stucture (Partitionoriented backup)

 

root@buster:/mnt/backup/raspberrypi# tree -L 2
.

├── raspberrypi-backup.blkid
├── raspberrypi-backup.fdisk
├── raspberrypi-backup.mbr
├── raspberrypi-backup.parted
├── raspberrypi-backup.sfdisk
├── mmcblk0p1
│   ├── bcm2708-rpi-b.dtb
│   ├── bcm2708-rpi-b-plus.dtb
│   ├── bcm2708-rpi-b-rev1.dtb
│   ├── bcm2708-rpi-cm.dtb
│   ├── bcm2708-rpi-zero.dtb
│   ├── bcm2708-rpi-zero-w.dtb
│   ├── bcm2709-rpi-2-b.dtb
│   ├── bcm2710-rpi-2-b.dtb
│   ├── bcm2710-rpi-3-b.dtb
│   ├── bcm2710-rpi-3-b-plus.dtb
│   ├── bcm2710-rpi-cm3.dtb
│   ├── bcm2711-rpi-400.dtb
│   ├── bcm2711-rpi-4-b.dtb
│   ├── bcm2711-rpi-cm4.dtb
│   ├── bootcode.bin
│   ├── cmdline.txt
│   ├── config.txt
│   ├── COPYING.linux
│   ├── fixup4cd.dat
│   ├── fixup4.dat
│   ├── fixup4db.dat
│   ├── fixup4x.dat
│   ├── fixup_cd.dat
│   ├── fixup.dat
│   ├── fixup_db.dat
│   ├── fixup_x.dat
│   ├── issue.txt
│   ├── kernel7.img
│   ├── kernel7l.img
│   ├── kernel8.img
│   ├── kernel.img
│   ├── LICENCE.broadcom
│   ├── overlays
│   ├── start4cd.elf
│   ├── start4db.elf
│   ├── start4.elf
│   ├── start4x.elf
│   ├── start_cd.elf
│   ├── start_db.elf
│   ├── start.elf
│   └── start_x.elf
├── mmcblk0p2
│   ├── backup
│   ├── bin
│   ├── boot
│   ├── dev
│   ├── etc
│   ├── home
│   ├── lib
│   ├── lost+found

│   ├── media
│   ├── mnt
│   ├── opt
│   ├── proc
│   ├── remote
│   ├── root
│   ├── run
│   ├── sbin
│   ├── srv
│   ├── sys
│   ├── tmp
│   ├── usr
│   └── var
├── raspiBackup.log
└── raspiBackup.msg

 

 

Disclaimer

This backup- and restorescript raspiBackup was initally created for personal use only. But it's very useful and it therefore was published for general use. It's seriously tested but it's not possible to guarantee the script works as expected in all possible environments. Everybody uses this script on his own risk. The creator of this script is not liable in any case for any malfunction.

 

Updatestrategy

From time to time a new version of raspiBackup is published with new functions, extensions and small fixes. raspiBackup then will create a message and will note the update in the eMail sent with a smiley :-). Use parameter -U to download and install the latest version. The current version will be saved and can be restore with parameter -V. Which new functions extensions and bugs are fixed read on version history. Updates are available every couple of months. Fixes for serious bugs will be published immediately.

Every new version is regression tested before it's published. See here about regression test details.

 

Languages

raspiBackup uses the sytem language to select the language. If the language is not supported English will be used.  If somebody wants to help to add to raspiBackup another language is coordially invited to do so.For details see here.

 

Donations

For details see here.

 

Statistics

 
raspiBackup checks every time when invoked once a day whether a new raspiBackup release or beta exists and writes a message to notify the raspiBackup user about the news. The check also passes some information about used raspiBackup options which allows to create general usage statistics. For January 2022 there are following statistics:
 
  1. 1500 avarage invocations per day
  2. 2300 invocations on Sunday
  3. rsync and dd are used about 40%. tar is used 20%
  4. Partitionoriented mode is mostly not used
 
Following options are exposed:
 
  1. Release
  2. Backuptype
  3. Backupmode
  4. Backup- or Restorecall
  5. Keep
  6. Parameters of the smart recycle strategy if used
  7. OS: RaspbianOS or Ubuntu
 
Option
 

DEFAULT_SEND_STATS=0

in config file /usr/local/etc/raspiBackup.conf disables the transfer of the options mentioned above.

 

 

Useful links related to backup

Shrinking images on Linux

rpi-clone: A shell script to clone a running Raspberry Pi SD card to a USB mounted SD card

sysmatt: Backup, Restore, Customize and Clone your Raspberry Pi SD Cards

Automatic RPi Image Downsizer

 

Other backuptools for Raspberry as raspiBackup

rpi-clone: Backup your Raspberry with rsync

piclone: Clone your SD card with cp. UI available on RaspbianOS desktop.

rclone: Backup into the cloud

image-backup: Nice backup tool from RonR

borg: Very powerful backuptool with deduplication

urbackup:

rpi-backup: Script to create an img Backup without dd.

pibackup: Create a dd backup, shrink the dd image and keep a configurable number of backups.

shrink-backup: Another backuptool which works similar as rpi-clone and image-backup. Cmdlinetool.

Add comment

*** Note ***

Comments are welcome. But in order to reject spam posts please consider following rules:
  1. Comments with string http are rejected with message You have no rights to use this tag
  2. All comments are reviewed by hand and thus it usually takes one day until a comment will be published.