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. Resote is possible on Windows or Linux.  Raspberry USB boot images and NOOBs images are supported.

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

raspiBackup is written in bash and is published on github .





  • Click FB f Logo blue 29 to ask questions or report issues on Github. 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 on Facebook.
  • Click Twitter f Logo blue 29 to follow raspiBackup on Twitter
  • Click Comment to create a comment.


Where to go next?

If you want to evaluate and test raspiBackup read this quickstart 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.  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.



  1. Summary
  2. Features
  3. High level overview
  4. Installation
  5. Invocationsyntax and -options (alphabetically sorted)
  6. Invocationsyntax and -options (theme sorted)
  7. Extensabilitiy
  8. Restore
  9. Errormessages and troubleshooting
  10. Backup types and decision tree
  11. Backupspace directory structure
  12. Disclaimer
  13. Updatestrategy
  14. Regressiontests
  15. Versionhistory
  16. Use Synology as backupspace
  17. Additional pages about raspiBackup
  18. FAQ
  19. Useful links related to backup
  20. Version history
  21. Credits
  22. Donations



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.

There exist two backup modes: 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 second backup mode (partitionoriented mode) will save all or a configurable number of partitions of the SD card. That way it's possible to save NOOBs images and SD cards with more than two partitions.

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.


  • Unattended backup of a running Raspberry PI (Pi backups itself)
  • Other similar SoCs are supported (Banana Pi, Ondroid, Beagle Board, Cubieboard, ...). For details see here.
  • Raspbian, Arch, Ubuntu, Volumio, NOOBs ...
  • Raspberry3 running without SD card (booted from USB) is supported
  • 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
  • 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 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
  • Simple restore of the backup
  • 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
  • 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)
  • 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)
  • 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


High level overviewraspiBackupOverview



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

raspiBackup has to be invoked as user root or with sudo. The invocation syntax is

raspiBackup.sh Option1 Option2 Option3 ... backupdirectory 
There are a lot of options available to customize the backup process. The most important parameters are marked in red. Some options require addition parameters as -k 3 or -m 1.

All default options can be overwritten in a configuration file /usr/local/etc/raspiBackup.conf. A sample configuration file which has the standard options defined can be downloaded here.

Starting with version all options which turn something on or off can be influenced by a trailing + or -. Example: Option -z and option -z+ turn on the backupcompression. Option -z- turns off the backupcompression and ignores the definition DEFAULT_ZIP_BACKUP in the configuration file. That way it's possible to turn off options in the commandline even they are turned on in the configuration file.

In addition to /usr/local/etc/raspiBackup.conf other config files are read if they exist. They are included in following sequence and overwrite the previous option settings. Last but not least the invocation options overwrite all previously defined options in the configuration files.

Priority Filename
5  /usr/local/etc/raspiBackup.conf
4 ~/.raspiBackup.conf
3 $(pwd)/.raspiBackup.conf
2 -f <configFile>
1  Invocation options


Options alphabetical sorted

Parameter Function Default Parameter in der Konfigdatei

Commands to start services stopped before the backup. Example "service xbmc start" (Attention: There are leading and trailing double quotes). This option is mandatory together with option -o.

Multiple commands have to be separated by && . As an alternative use a wrapperscript (See below). The commands should have the inverse sequence as the commands used for the  -o parameter.


-a "service nfs-kernel-server start && service samba start"

If there are no services to stop use a colon ":" as parameter.

See also FAQ#1 and FAQ#18


All commands are executed as root. There is no sudo required.




Send the log in the notification email as attachement no




-b Blocksize used in the dd command 1MB




-B Boot partition will be save with tar instead of dd No




 -D Addition invocation parameters for dd command (e.G.. "conv=notrunc,noerror,sync")  None




 -e email address which will get a notification eMail  None




Optional additional parameters which are passed in the eMail call. For sendEmail use "-f sender.mail@senderdomain -s smtp-server:587 -xu username -xp password".

Attention: The parameters for -E have to have a leading and trailing double quote ". It's  useful to use parameter -F to speed up the test of the email notification function

Attention: If option -l 1 is used the password will be logged in the log file. Masquerade the password before sending the log to somebody.





-f Available starting with v0.6.4.2: Configuration file which is includes last. See here for all configuration files and their precedence. No  
-F Fake backup. This option is useful when raspiBackup is initially tested. The time consuming backup is not started but all the parameters are checked and an email is sent. No  
-g This option enables a progress bar during backup and restore.    
-G Define language of messages. Possible messages are DE (German) and EN (English). Volunteers to translate the messages into another languages are welcome.  Please contact me for details.

System language

If the system language is not supported EN (English) is used.



 -h  Help  No  
 -k Number of backups to keep per backup type. If you use the default you keep 3 dd, 3 tar and 3 rsync backups.  3




Log level defines whether a debug log will be created:

- off  -> No debug log

- debug -> Create debug log

Attention:  Logfile may contain sensitive data in some situations (E.g. external static IP addresses, eMailAddresses, passwords for mount commands or eMail server ...)






Message details:

- minimal -> Write important messages only

- detailed -> Write a lot of messages to show the progress





-M This option allows to modify the backup directoryname. That way it's possibe to create backups in addition to the regular backups and give the backups meaningful names.    
-n Notify if there is a newer version of raspiBackup available Yes




-N Activation of plugins to activate custom code. See this page for details which also offers three sample plugins which report the CPU temperature and the memory utilization before and after the backup run. None




Commands to stop services before the backup. Example "service smb stop" (Attention: There are leading and trailing double quotes). This option is mandatory together with option -a.

Multiple commands have to be separated by && . As an alternative use a wrapperscript (See below). The commands should have the inverse sequences as the commands used for the  -a parameter


-o "service samba stop && service nfs-kernel-server stop"

If there are no services to stop use a colon ":" as parameter.

See also FAQ#1 and FAQ#18 


All commands are executed as root. There is no sudo required.





Enables the partitionoriented backup mode which saves all partitions or a selected number of partitions of the SD card. This mode should be used with NOOBs images when using tar or rsync backup type and for images which have more than 2 partitions. If a NOOBS image should be saved via dd so it's possible to restore the backup with win32diskimager use the normal backup mode with dd backup type.

See also parameter -T.

Note: If this option is used an external root partition cannot be saved.






email program to use to sent the notification eMail  {mail|sendEmail|ssmtp|msmtp}. Use mail also for mailx. For sendEmail use also parameter -E to pass mandatory parameters (See parameter -E description for details)

Other eMailClients can be used via an eMailPlugin Then mailext has to passed as the parameter. See this page for details about the eMailPlugin.




--systemstatus Starting with version a list of running services and open files is reported in the debug logfile.    

Backup type which can be dd, tar or rsync. rsync uses hardlinks if the backupfilesystem is an ext3/ext4 partition  See details of the backuptypes. An external root filesystem will be saved if tar or rsync backup is used and option -P is not selected. Parameter -z can be used in addition to zip the backups to reduce the backup size.

Note: dd backup can be controlled by configuration parameter DEFAULT_DD_BACKUP_SAVE_USED_PARTITIONS_ONLY which saves backuptime and -space. For details of the parameter see bottom of table.





If the partitionoriented backupmode is selected with option -P this parameter can be used to define which partitions should be saved. Example: -T "1 2 5" saves the first two partitions and the fifth partition. * saves all partitions. 






--timestamps  Starting with version this option can be used to prefix all messages with a timestamp. No DEFAULT_TIMESTAMPS
Extension of the excludelist for a backup to exlude special files and directories.

Attention: Parameters have to follow the syntax of the backuptool used. Otherwise the backup will fail. Example for rsync or tar:

"--exclude=/backup/* --exclude=/rsnapshot/* --exclude=/www-data*/*".

Additional information about the syntax is available on the man pages of the backup tools used.

Following directories are not saved:
Backuppath used in invocation, /proc/* , /lost+found/* , /sys/* , /dev/* , /tmp/*, /boot/*, /run/* , /proc/* , /lost+found/* , /sys/* , /dev/* , /tmp/* , /boot/* , /run/*
In addition all mounted directories from external devices which are not mounted on / are not saved. It's only the boot parition /dev/mmcblk0p1 and the root partition /dev/mmcblk0p2 or the external root filesystem on /dev/sda1 which is saved.
Note for partitionoriented backup mode:
If option -P is used the directories mentioned above are exluded in all partition backups.
   */directory/* - Excludes directory on all partitions
   mmcblk0p2/verzeichnis/* - Excludes directory on partition mmcblk0p2
   directory/* - Excludes directory on all partitions





Upgrades the current raspiBackup version with the latest available version. The previous one will be saved as raspiBackup.sh.n.m where n and m are the versionnumbers of raspiBackup.

Attention: Read this page and understand which changes and new functions will become available before upgrading.

-v Verbose mode of the backup tools tar and rsync. This option is useful during initial manual backup tests in order to see the backup progress. No



-V Presents a list of existing previous version and allows to select one of the version to restore. The actual version will be saved and can be restored later on. See also parameter -U. (Available with Release 0.6) No  

Starting with version the current version information of raspiBackup is returned in following format:

Version: CommitSHA: 8fbcd1a CommitDate: 2018-02-19 CommitTime: 19:18:31

That way it's possible to query the current version information in a programmatic way.

-y This option starts the deployment of the actual script to hosts which are defined in the configuration file. Access has to be possible without password and requires the keys to be copied into authorized_keys . That way you can quickly deploy a new script version on multiple hosts. No




-z Use gzip with dd or tar backup to reduce the backup size No





An eMail will be sent only in case of backup failure Note: If raspiBackup crashes because of unexpected reasons it may happen there is no eMail send even the backup failed.

You use this option on your own risk.








Backupoptions used by rsync backup.

You use this option on your own risk.

--delete -aHAXx





  Backupoptions used by tarbackup. You use this option on your own risk. -cpi






Additional backupoptions used by rsync backup.

You use this option on your own risk.








Additional backupoptions used by rsync backup.

You use this option on your own risk.







  Bootpartition backups use hardlinks to minimze the backupspace because bootpartitions don't change often. Note: Ssupport of hardlinks on the backupspace required (ext3/ext4 filesystem) No





dd backup only saves the space used by defined partitions. That way a backup of a 32 GB SD card with a 8GB partition only needs 8GB. The root partition in general uses the the whole SD card and has to be resized with gparted or resize2fs first appropriately.

See also FAQ#16





  This option is used to append the log to the eMail -a DEFAULT_APPEND_LOG_OPTION
  Define the sender eMail root@$(hostname) DEFAULT_SENDER_EMAIL

Starting with version Backup restore test reminder Intervall (Unit: Months)

  Starting with version Number of reminders to execute a backup restore test 3 DEFAULT_RESTORE_REMINDER_REPEAT
Note: Options in the config file which are set to yes or no have to be set as 0 for no and 1 for yes.
All options for the restore of a backup are described here.

Options theme sorted



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



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.sh 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 corntab
2) Use parameter -l debug (lowercase L) when invoking the script and check the logfile raspiBackup.log written by raspiBackup into the current directory for
error messages. (Parameter -L defines the location of the log file. See also the parameterdescription for -L. 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


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 and this allows to save NOOBS images and images with more than 2 partitions. 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
├── 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
│   ├── 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


Backupspace directory structure (Partitionoriented backup) 

root@jessie:/mnt/backup/raspberrypi# tree -L 2
├── raspberrypi-dd-backup-20160415-222923
│   └── raspberrypi-dd-backup-20160415-222923.img
├── raspberrypi-rsync-backup-20160416-104548
│   ├── mmcblk0p1
│   ├── mmcblk0p2
│   ├── raspberrypi-backup.blkid
│   ├── raspberrypi-backup.fdisk
│   ├── raspberrypi-backup.mbr
│   ├── raspberrypi-backup.parted
│   └── raspberrypi-backup.sfdisk
└── raspberrypi-tar-backup-20160416-114748
    ├── mmcblk0p1.tar
    ├── mmcblk0p2.tar
    ├── raspberrypi-backup.blkid
    ├── raspberrypi-backup.fdisk
    ├── raspberrypi-backup.mbr
    ├── raspberrypi-backup.parted
    └── raspberrypi-backup.sfdisk


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.



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.



If you want to honor the development and maintenance effort or the support for raspiBackup just grab the eMail mentioned on the contact page and send a donation via PayPal to this eMail. You will then added in this list. Just let me know if you don't want to be listed there.

One raspiBackup user wanted to donate in Bitcoins. Thus I created a wallet. Use following wallet address: 13aXub22Sy3AvTKkj14yvnUdMQYJQFdbRo


Additional pages about raspiBackup

All articles about raspiBackup on this website


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

How to extend a NOOBS partition



Add comment


Spam comments are purged and not published. Review is done manually and therefore it usually takes between some hours and one day until a comment will be published.