0) Where does raspiBackup come from?

I run three Raspberries at home. Two of them run 7/24 all the time as LAN servers. It's common practice to backup a server on a regular base just in case there are any failures. In particular the SD card of the Raspberry tends to fail after some time. That's why I wrote a small script which created a dd backup. Then a tar backup was possible to create because the dd backup saves the whole SD card all the time even there is only a subset of the space used. Finally a rsync backup was introduced to use hardlinks and save backupspace. raspiBackup helped me multiple times to revover from a broken SD card so I thought the script may also be very helpful for other people running Raspberries and decided to publish raspiBackup.

1) Does it work to create a backup from a running system? Shouldn't the system be stopped first?

The most reliable backup is a backup from a stopped system. Unfortunately this cannot be done on a regular base with cron automatically. If you stop all active services as mysql, samba, nfs, seafile, Owncloud, Webserver and all other active services before starting the backup in order to keep all the data consistent the backup can be used to restore the system. If these services are not stopped there is a high probability that the backup will become inconsistent. Parameter -a and -o help to achieve for this. See also FAQ 18. As an alternative a sample wrapper script can be used and extended .

2) How can I restore a backup?

raspiBackup can restore all created backups (See this page for details). raspiBackup runs on Linux only. Windows user can use windisk32imager to restore a dd backup. For all other backup types a Linux system is required.

Fortunately your Raspberry can be used to restore the backup with raspiBackup. Install a Linux OS (e.g. raspbian) on a second SD card, start it and install raspiBackup.  Now connect an external SD card reader and the drive with the backup and use raspiBackup to restore the backup to the external SD card. Shutdown the system, insert the external SD card with the restored backup and start your Raspberry again.

3) What will be saved and restored by raspiBackup?

raspiBackup can save two partitionens in the normal backup mode: The boot and the rootpartition of the SD card. If the rootpartition was moved to an external partition this external partition is also saved. An unlimited number of partitions on the SD card will be saved in the partition oriented mode. Additional external partitions will not be saved in this mode. This mode is usefull for NOOBs images.

4) Which Linux methods to create backups can be used?

You can use dd, tar and rsync to backup the data.  dd and tar backups can be zipped also. See the following page for pros and cons of the different backup methods.

5) Can the backup created by raspiBackup be used to restore the backup manually?

That was a requirement for raspiBackup: It should be possible to restore the backup with Linux means only.

raspiBackup creates readable files of the output of the Linux commands sfdisk, blkid and fdisk of the SD card. This allows to restore the partition layout of the original SD card with Linux means. Then the partition backups can be restored into these partition using the corresponding linux backup tools.

6) Can a backup be restored on a smaller or larger SD card than the original SD card?

That works perfectly for larger SD cards. But the additional space will not be used. To use the additional space a Linux repartitioning tool has to be used when the backup was restored.

Starting with version this works perfectly for smaller and larger SD cards. The root partition size is adjusted accordingly. It's either truncated if the SD card is smaller than the original SD card or expanded to use the whole SD card size if it's larger. If it's expanded no repartitioning is needed any more. This works for tar and rsync backup in the normal backup mode.

If the existing partitioning of the backup should be used for the restore the option -1 (one) disables this automatic repartitioning. Option -0 (zero) allows to use the existing partitioning of the target SD card.

7) How can I control the partitioning of the target SD card?

There exist two options which give you full control of the way the new SD card is partitioned. Option -1 (one) forces raspiBackup to create the same partitioning on the target SD card even the partitions are smaller or larger than the size of the target SD card. Option -0 (zero) disables partitioning by raspBackup. This allows to create the partitioning and formating on the target SD card upfront and these paritions are used as is by raspiBackup during restore.

8) On which devices can raspiBackup save the backup?

In general on every device which can be mounted on Linux:

  • External USB Stick
  • External USB disk
  • Synology
  • cifs/samba networking disk
  • nfs networking disk
  • sshfs networking disk
  • webdav networking disk
  • ftpfs networking disk

9) There is some data on my system which raspiBackup doesn't save. How can I include this data in the backup?

Use one of the following approaches:

a) Use a wrapper script  (see here) and write your own code which is executed before and after raspiBackup and saves additional data

b) Use extension points which are called before and after the backup function to save the data. There exist two sample extensions (see here) which report the CPU temperature before and after a backup run and the used memory. An eMailExtension can be used to plug in your own eMailClient.

10) Which eMailClients are supported by raspiBackup?

mailx, sendEmail and ssmtp are supported. The eMailExtension plugpoint can be used to plugin every other eMailClient (Details see here).

11) My mailProgram is not supported by raspiBackup. How can I now get eMails from raspiBackup?

Use the eMalExtension plugpoint to write a small extension which will be used to send the emails from raspiBackup. The existing extensionsamples include one sample code for the mailx eMailClient.

12) Ich have a question about raspiBackup. How do I get an answer?

At the bottom of every webspage you can create comments. Just ask your question there. To eliminate spam the comments are checked manually and that's why it usually takes one day until the comment is published and will be answered. The eMailAdress which is optional, will not be published. It's required to get update notifications about new comments and may also be used to get in contact offline.

13) I found a bug in raspiBackup. How can I report the bug and when do I get a fix?

nichtEvery software can have bugs and thus it's possible for raspiBackup also. Report the bug in a comment on the webpage and add your eMailAdress. Now you will be either asked in followon comments to provide additional details about the bugor you will be contacted via eMail and asked to create a detailed log and send it via eMail for problemanalysis. Usually you will get a fix quite fast sent in an eMail and should verify the fix. If the fix was verified successfully it will be published.

14) Do I get any notification if there is a new version available?

raspiBackup checks in every invocation whether there exist a new version. A message will be written and the notification eMail will have a smiley ;-) in it's mail title. Now you can check on this page what's new in the new version and update raspiBackup with parameter -U.

15) How can I revert to the previous raspiBackup version if I detect the new version doesn't work as expected when I upgraded?

raspiBackup creates a backup copy every time an upgrade is done with parameter -U. Option -V can be used to revert to a previous version. A list of all saved raspiBackup versions will be presented and the version to restore can be selected.

16) I have a 32GB SD card but need only 8GB. The dd backup uses 32GB instead of 8GB.

dd backup backups the whole SD card Starting with version there is a configuration parameter which causes raspiBackup to save only the space used by defined partitions. So you just have to resize the 32GB partition to 8GB with gparted or other repartitiontools and the backup will only use 8GB. Current partiton sizes can be checked with lsblk command.

17) How can I check whether rsync backup uses hardlinks and backup space is saved?

Command du -sh * displays the used backup space and du -shl * displays how much space would be used if no hardlinks are used.


root@raspberrypi:/media/nas-backup/raspberrypi# du -sh *
4,5G raspberrypi-rsync-backup-20160822-184617
4,5M raspberrypi-rsync-backup-20160822-190436
5,2M raspberrypi-rsync-backup-20160822-195250
5,7M raspberrypi-rsync-backup-20160822-201610

root@raspberrypi:/media/nas-backup/raspberrypi# du -shl *
4,7G raspberrypi-rsync-backup-20160822-184617
4,7G raspberrypi-rsync-backup-20160822-190436
4,7G raspberrypi-rsync-backup-20160822-195250
4,7G raspberrypi-rsync-backup-20160822-201610

18) Which services have to be stopped before starting the backup and started again afterwards?

All services which keep any states in databases or in memory or on filesystemhave to be stopped. Otherwise inconsistent data will be saved and this will be detected when the backup is restored and the backup is unusable. raspiBackup offers option -o to stop services before starting the backup and option -a to start the services afterwards.

Following services have to be stopped with option -o in any case:

Service Stop command
nfs service nfs-kernel-serv er stop
Samba service samba stop
Pilight service pilight stop
Cups service cups stop
Minidlna service minidlna stop
Apache service apache2 stop
Wordpress service wordpress stop
nginx service nginx stop
seafile service seafile stop
Owncloud see Apache
mysql service mysql stop
FHEM /etc/init.d/fhem stop
cron service cron stop


To start the services again use option -a and use the reverse service sequence used with -o. If you are dead certain you don't need to stop and start services use ":" as parameter for option -a and -o.

19) Which format should be used on the backup partition?

In general every filesystem can be used which can be mounted on LInux. But there are following constraints:

- rsync backup reuqires supprot for hardlinks which is available with ext3/4. If an ext4 filesystem is exported via samba there is no support for hardlinks. NFS is an alternative.

- FAT32 can store files with max 4GB only. A dd backup will become as large as the SD card is (Configuration option DEFAULT_DD_BACKUP_SAVE_USED_PARTITIONS_ONLY can reduce the size) and is in genaral larger than 4GB. It's similar for tar backups which become larger than 4GB quite quickly. An alternative may be NTFS on windows.

General suggestion: Use ext3/4 if possible. On Linux use NFS for remote drives. On windows NTFS for exported samba network drives. Use FAT32 only if you are sure the backup files will not become larger than 4GB,



Add comment

Spam Kommentare sind sinnlos denn sie werden nicht publiziert. Sie werden vor der Publizierung auf Spam geprüft. Deshalb kann es aber etwas dauern bis ein Kommentar sichtbar wird.
Die eMail ist optional und nicht öffentlich sichtbar Sie wird u.U. genutzt um offline zu kommunizieren

Spam comments are useless because they will not be published. Before they are published they are checked for spam. Therefore it may take some time until the comment is published.
eMail is optional and hidden and may be used to contact you offline


0 #2 framp 2016-08-13 09:41
Hi Clark,

I tried to answer your question in FAQ #3. Looks like there is some information missing :oops:

raspiBackups initial purpose was to backup the SD card only. At some point in time a user asked whether it's possible to enhance raspiBackup to save an external root partition also (You modify /boot/cmdline.t xt to use an external SD card or use raspiSD2USB.py https://www.linux-tips-and-tricks.de/en/raspberry/475-how-to-move-a-root-partition-of-a-raspberry-pi-to-an-external-partition). I found this request to be a common usecase and added this functionality.
The partition oriented mode which allows to backup more than 2 partitions just saves the SD card partitions.
If you mount and use in addition other external partitions on your raspi as data disks they are not backuped. But you can use the wrapper script I provide (https://www.linux-tips-and-tricks.de/de/raspberry/23-pi-erstellt-automatisch-backups-von-sich-selbst-pi-creates-automatic-backups-of-itself#wrapper) to backup and restore them when raspiBackup finishes it's backup processing.

Hope this answers your question.

Cu framp
0 #1 Clark 2016-08-12 23:53
Is there a way to backup data from an external hard drive instead of the (root) partition(s) of the raspberry´s sd card?