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 video where raspiBackup is introduced and at the end a demo of the installation of raspiBackup is given.
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
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
to read news and background information in English about raspiBackup or ask questions. Please report issues on github..
- Click
to view Youtube videos about raspiBackup
- Click
to follow raspiBackup on Twitter
- Click
to ask a question in a comment. Please report issues on github.
- Click
if you want to know how to donate if you like 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.
Index
- Summary
- Features
- High level overview
- Installation
- Invocation syntax
- Invocationsyntax and -options (alphabetically sorted)
- Invocationsyntax and -options (theme sorted)
- Extensabilitiy
- Restore
- Errormessages and troubleshooting
- Backup types and decision tree
- Backupspace directory structure
- Disclaimer
- Updatestrategy
- Languages
- Regressiontests
- Versionhistory
- Use Synology as backupspace
- Additional pages about raspiBackup
- FAQ
- Useful links related to backup
- Version history
- Credits
- Donations
- 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 overview
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
raspiBackup has to be invoked as user root or with sudo. The invocation syntax is
raspiBackup.sh Option1 Option2 Option3 ... backupdirectory
raspiBackup Option1 Option2 Option3 ... backupdirectory
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.
All options which turn something on or off can be controlled 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 overide the previous option settings. Last but not least the invocation options overide 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 theme sorted
- Options, which configure the backup
- Options, which configure the messages and logs
- Options, which configure the notification email
- Options, which update, restore and distribute raspiBackup
- Options, which start and stop services and run plugins before and after backup processing
- Miscellaneous options
Options alphabetical sorted
Parameter | Function | Default | Option can be set in installer | Option in configuration file |
-a |
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. Example:
If there are no services to stop use a colon ":" as parameter. Note: All commands are executed as root. There is no sudo required. |
None | yes |
DEFAULT_ STARTSERVICES |
-b | Blocksize used in the dd command | 1MB | no |
DEFAULT_ DD_ BLOCKSIZE |
-B |
Boot partition will be save with tar instead of dd Note: This option has no function if partition oriented mode is used and option -P is used or DEFAULT_PARTITIONBASED_BACKUP=1 is defined in the configuration file. |
No | no |
DEFAULT_ TAR_ BOOT_ PARTITION_ ENABLED |
--coloring | Starting with version 0.6.5 messages can be colorized. Possible parms C for console and/or M for eMail. See also option --eMailColoring if you use the postfix eMailClient. | CM | no |
DEFAULT_ COLORING |
-D | Addition invocation parameters for dd command (e.G.. "conv=notrunc,noerror,sync") | None | no |
DEFAULT_ DD_ PARMS |
--dynamic Mount |
Starting with version 0.6.6 the specified mount point or partition will be mounted during startup and umounted at the end. If it's already mounted it's not umounted at the end. The mount point has to be defined in /etc/fstab. The option argument can either be the mount point (e.g. /backup) or the backup partition name (e.g. /dev/sdb1). | None | no |
DEFAULT_ DYNAMIC_ MOUNT |
-e | email address which will get a notification eMail | None | yes |
DEFAULT_ |
-E |
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. |
None | no |
DEFAULT_ EMAIL_ PARMS |
Coloring |
Default is to use the subject header in eMails to control eMail coloring because that's the way used by most of the emailCients. If postfix is used then parameter OPTION has to be used because postfix uses a dedicated option to control email coloring. |
SUBJECT | no |
DEFAULT_ EMAIL_ COLORING |
-f | Configuration file which is includes last. See here for all configuration files and their precedence. | No | 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 | no | |
-g | This option enables a progress bar during backup and restore. | no | ||
-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. |
yes |
DEFAULT_ LANGUAGE |
-h | Help | No | no | |
--ignore Additional Partitions |
Starting with version 0.6.5 raspiBackup allows to have more than two partitions on the SD card when tar or rsync backup is used. But only the first two partitions, /boot and / are saved and restored. Attention: All other paritions are not saved. | No | no |
DEFAULT_ IGNORE_ ADDITIONAL_ PARTITIONS |
-k |
Number of backups to keep for all backup types if not overridden by following option. If you use the default you keep 3 dd, 3 tar and 3 rsync backups. Note: This option is ignored when intelligent rotaion strategy is used. |
3 | yes |
DEFAULT_ KEEPBACKUPS |
--keep_<type> |
Starting with version 0.6.4.3: Number of backups to keep for the specific backup type. <type> can be any backup type, eg dd, ddz, tar, tgz or rsync Note: These options are ignored when intelligent rotaion strategy is used. |
Parameter for option -k | no |
DEFAULT_ KEEPBACKUPS_ {DD|DDZ|TAR| TGZ|RSYNC} |
-l |
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 ...). The debug logs are stored in the backup location. In case the backup fails and the backup directory will be cleaned up the debug log is saved in the home directory of the caller first. |
on | no |
DEFAULT_ LOG_ LEVEL |
-L |
Defines the log target for raspiBackup.log varlog: Target is /var/log/raspiBackup.log backup: Log will be stored in created backup current: Use current directory <filename>: Write log into <filename>. In addition the messages are written into a .msg file. |
backup | no |
DEFAULT_ LOG_ OUTPUT |
-m |
- minimal -> Write important messages only - detailed -> Write a lot of messages to show the progress |
minimal | yes |
DEFAULT_ MSG_ LEVEL |
-M |
This option allows to add some text to the backup directoryname. That way it's possibe to create backups in addition to the regular backups and give the backup directories names which describe the backup. Note: These backup directories are not included in the backup recycle process and have to be deleted manually. |
no | ||
-n | Notify if there is a newer version of raspiBackup available | Yes | no |
DEFAULT_ NOTIFY_ UPDATE |
-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 | no |
DEFAULT_ EXTENSIONS |
--notify Start |
Starting with version 0.6.5 it's possible to get an eMail or Telegram notification when raspiBackup starts. Default is to send an eMail or notification only when raspiBackup finishes. | No | no |
DEFAULT_ NOTIFY_ START |
-o |
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 Example:
If there are no services to stop use a colon ":" as parameter. Note: All commands are executed as root. There is no sudo required. |
None | yes |
DEFAULT_ STOPSERVICES |
-P | Enable partitionoriented mode which allows to save more than the first two partitions which are saved in the normal mode. Use parameter -T to define which partitions should be saved. | off | yes |
DEFAULT_ PARTITIONBASED_ BACKUP |
--reboot System |
Starting with release 0.6.7 this option initiates a reboot when the backup run finished. This way all services are restarted again. Arguments passed with option -a will be ignored because of this. Note: If option -F is used no reboot will be executed. |
off | no |
DEFAUL_ REBOOT_ SYSTEM |
-s |
email program to use to sent the notification eMail {mail|sendEmail|ssmtp|msmtp}. Use mail also for postfix and nullmailer and install mailtools. 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. |
no |
DEFAULT_ MAILPROGRAM |
|
-S | An update with option -U is executed even the versions are identical. A local betaversion and a local normal version will be replaced with the latest code level. It's primarily used to update a local beta version to the latest code level. | off | no | |
--smart Recycle |
Starting with version 0.6.5 this option enables the intelligent rotationstrategy. For details see here. This also disables all --keep options and they don't have to be disabled by setting them to 0. | off | yes |
DEFAULT_ SMART_ RECYCLE |
--smart Recycle Dryrun |
Starting with version 0.6.5 this option enables or disables the test mode of the intelligent rotationstrategy on. For details see here. |
yes | no |
DEFAULT_ SMART_ RECYCLE_ DRYRUN |
--smart Recycle Options |
Starting with version 0.6.5 this option defines the intelligent rotationstrategy parameters. For details see here. | "7 4 12 1" | yes |
DEFAULT_ SMART_ RECYCLE_ OPTIONS |
--system status |
A list of running services and open files is reported in the debug logfile. | no | ||
-t |
Backup type which can be dd, tar or rsync. rsync uses hardlinks if the backupfilesystem is an ext3/ext4 partition Attention: rsync should not be used with NTFS formatted Backuppartitions because cannot store the access rights of an ext3/4 filesystem correctly. Therefore the access rights cannot be restored correctly on an ext3/4 filesystem and the restored image is unusable. In addition hardlinks are supported only on ext3/4 filesystems in order to minimze disk space usage. 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. |
dd | yes |
DEFAULT_ BACKUPTYPE |
-T |
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. |
* until release 0.6.5.1 "1 2" starting with release 0.6.6 |
yes |
DEFAULT_ PARTITIONS_ TO_ BACKUP |
--telegram --telegram ChatID --telegram Notifications |
Starting with version 0.6.5 Telegram notifications are supported. You have to configure the token and chatid. Notifications option can be S for success and/or F for failure. With "M" raspiBackup messages are attached in a file.. With "m" raspiBackup messages are sent too. Any of these options can be combined. Example: "SFM" or "Sm". Options "M" and "m" cannot be used together. |
Off F |
no |
DEFAULT_ TELEGRAM_ TOKEN DEFAULT_ TELEGRAM_ CHATID TELEGRAM_ NOTIFICATIONS |
--timestamps | This option can be used to prefix all messages with a timestamp. | No | no |
DEFAULT_ TIMESTAMPS |
-u |
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*/*"
Note the enclosing double quotes! 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.
rsync:
*/directory/* - Excludes directory on all partitions
mmcblk0p2/verzeichnis/* - Excludes directory on partition mmcblk0p2
tar:
directory/* - Excludes directory on all partitions
|
None | no |
DEFAULT_ EXCLUDE_ LIST |
--unsupported Environment |
Starting with release 0.6.7 this option allows to start raspiBackup also on unsupported environments. For details read this article. | off | no | |
-U |
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. See also option -S which forces an update with the latest version even the versions are identical. |
No | no | |
--updateUUIDs | Starting with release 0.6.4.4: A restore will create partitions with the same UUIDs and PARTUUIDs of the original system. This option will create new UUIDs and PARTUUIDs on the restored partitions. | No | no |
DEFAULT_ UPDATE_ UUIDS |
-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 | no |
DEFAULT_ VERBOSE |
-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 | no | |
--version |
Display the version information of raspiBackup in following format: Version: 0.6.3.2 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. |
No | no | |
-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 | no |
DEFAULT_ DEPLOYMENT_ HOSTS |
-z | Use gzip with dd or tar backup to reduce the backup size | No | yes |
DEFAULT_ ZIP_ BACKUP |
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. |
No | no |
DEFAULT_ MAIL_ ON_ ERROR_ ONLY |
|
Backupoptions used by rsync backup. You use this option on your own risk. |
--delete -aHAx | no |
DEFAULT_ RSYNC_ BACKUP_ OPTIONS |
|
Backupoptions used by tarbackup. You use this option on your own risk. | -cpi | no |
DEFAULT_ TAR_ BACKUP_ OPTIONS |
|
Additional backupoptions used by rsync backup. You use this option on your own risk. |
no |
DEFAULT_ RSYNC_ BACKUP_ ADDITIONAL_ OPTIONS |
||
Additional backupoptions used by rsync backup. You use this option on your own risk. |
no |
DEFAULT_ TAR_ BACKUP_ ADDITIONAL_ OPTIONS |
||
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 | no |
DEFAULT_ LINK_ BOOTPARTITIONFILES |
|
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 |
No | no |
DEFAULT_ DD_ BACKUP_ SAVE_ USED_ PARTITIONS_ ONLY |
|
This option is used to append the log to the eMail | -a | no |
DEFAULT_ APPEND_ LOG_ OPTION |
|
Define the sender eMail for ssmtp and msmtp. | root@$(hostname) | no |
DEFAULT_ SENDER_ |
|
Backup restore test reminder Intervall (Unit: Months) |
6 | no |
DEFAULT_ RESTORE_ REMINDER_ INTERVAL |
|
Number of reminders to execute a backup restore test | 3 | no |
DEFAULT_ RESTORE_ REMINDER_ REPEAT |
|
Starting with version 0.6.4.3: Defined commands are executes before and after backup creation and before stopping and after starting system services (options -a and -o) | No | no |
DEFAULT_ BEFORE_ STOPSERVICES DEFAULT_ AFTER_ STARTSERVICES |
|
Starting with version 0.6.7 you can define a pre and post exit which is executed when a backup is restored. The syntax is identical to the extsion format for backups. | Empty | no |
DEFAULT_ RESTORE_ EXTENSIONS |
|
Starting with version 0.6.7 you can redefine the color codes used for emails and console. The first pair defines the colors for warnings and the second pair the colors for errors. The first element of the pair is the HTML color code The second element defined the VT100 color code. | ("#FF8000 33" "#FF0000 31") |
no |
DEFAULT_ RESTORE_ EXTENSIONS |
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 backupFollowing 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
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
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.
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 |

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.
- .img - Bootpartition of the SD card
- .mbr - Master boot record of the SD card
- .sfdisk - Partitionlayout of the SD card - Result of sfdisk command
- .blkid - (Partitionoriented backup only) - Result of blkid command
- .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.
Additional pages about raspiBackup
All articles about raspiBackup on this website
- 1500 avarage invocations per day
- 2300 invocation on Sunday
- rsync and dd ar used for about 40% genutzt. tar is used 20%
- Partitionoriented mode is mostly not used
- Release
- Backuptype
- Backupmode
- Backup- or Restorecall
- Keep
- Parameters of the smart recycle strategy if used
DEFAULT_SEND_STATS=0
in config file /usr/local/etc/raspiBackup.conf allows to disable the transfer of the options mentioned above.
Useful links related to backup
sysmatt: Backup, Restore, Customize and Clone your Raspberry Pi SD Cards
How To Take Hot Backup Of Raspberry Pi Without Removing The SD Card
Other backuptools for raspberry
rpi-clone: Backup your Raspberry with rsync
piclone: Clone your SD card with cp. Script and UI available in Raspbian
rclone: Backup into the cloud
Automating backups on a Raspberry Pi NAS: Create and keep 7 daily, 4 weekly, 12 monthlyand 5 yearly backups. This funktion is available with a helperscript in raspiBackup.
borg: Very powerful backuptool
Running Raspbian from USB devices: File Utilities RonR on raspberrypi.org/forum, includes image-backup (create dd image) and image-shrink (shrink dd images), Convert a SD imag into USB bootable image and much more
rpi-backup Script to create an img Backup without dd.
*** Note ***
Comments are welcome. But in order to reject spam posts please consider following rules: