User Rating: 3 / 5

Star ActiveStar ActiveStar ActiveStar InactiveStar Inactive
 

With raspiBackup you can create regular backups of your Raspberry. In addition you can restore a backup to any SD card. A new partition table is created on the target SD card and the backup data is restored on the partitions. If an external root filesystem was saved with raspiBackup this filesystem will also be restored to an external device.

Recently I got issues in github because restore failed. It's strictly recommended to restore your backup with the same OS the backup was created with. You're free to use another Linux release but this may the restore to fail because of different versions of the Linux tools which are usedto backup and restore the backup. In particular it's because of an incompatible change in sfdisk in Bullseye. Just use the OS the backup was created to restore the backup!
 

 

raspiBackup - How to restore your backup

 

Features

  • Simple restore of backups for windows, mac or linux users by using the Raspberry Pi
  • Messages in English and German
  • External rootfilesystem will be restored if the normal backup mode was used during backup and tar or rsync backup mode was used. USB boot systems will restore any external partitions starting with release 0.6.6.
  • Can be used to clone Raspberry Pis
  • Simple update to the latest version (-U parameter)

 

Contents

Invocationsyntax and -options

Restorescenario for Windows- or Macusers

Restorescenario for Linuxusers

Restore command examples

  1. Restore boot and root partition to SD card
  2. Restore the boot partition to SD card and the root partition to an external partition

 

Note1

Every backup should be tested on a regular base to check whether a restore still works and still contains all required data. It's ugly if you detect at the time you want to restore the backup that the backup is corrupt or there is data missing. A restore test is quite simple: Just insert a new SD card, restore a backup and boot the restored backup.

If the restore fails for any reasons with raspiBackup the backup can also be restored with the standard Linux tools used to create the backups - dd, tar or rsync - but will not as convenient as a restore executed with raspiBackup.

 

Note2

Use the same operating system for restore which was used to create the backup. There are incompatible output format changes which cause the restore to fail. As of now it's the sfdisk output format which changed between Wheezy and Jessie and causes the repartitioning to fail.

 

Invocationsyntax and -options

raspiBackup has to be executes as root or with sudo.

raspiBackup.sh Option1 Option2 Option3 ... backupdirectory

and starting with Release 0.6.6 you can omit the extension .sh

raspiBackup Option1 Option2 Option3 ... backupdirectory

 

Option -R defines, whether a single SD card restore will be executed or an external root partition will also be restored to an external partition.

Starting with version 0.6.3.2 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.

 

Parameter Function Default
-C Format of the restore partition will check for bad blocks by using option -c to mkfs.ext4. Note: This will slow down the restore (Starting with V0.6.3.2) Off
-d

SD card device or USB stick. Example: e.g. /dev/sda. The size of the root partition will be adjusted if the SD card or USB stick is larger or smaller than the backup SD card.

Note: A partition, e.g. /dev/sda1 will be rejected.

Attention: This device will be formatted and all existing data will be deleted. Make sure this device is the right one!

Note: This SD card should not be the SD card currently used by the operating system. Use a second SD card connected via USB card reader.

No
-R

This option allows to restore backups taken on systems which use an external root file system on USB or disk. Parameter defines the partition which will be used to restore the root partition. Example: /dev/sdb1

Note: This option should be used only if an SD card and an external root partition on USB stick is used. Otherwise option -d is sufficient.

Attention: This partition will be formatted. Make sure this partition is the right one and it's large enough to receive the restored root partition !

Note: This option works only for tar and rsync backups and if the backup was created in the normal backup modus. If option -P was used no external root filesystem will be available.

No

--resizeRootFS

Starting with version 0.6.3.2:

During restore the root filesystem will be resized to use the whole SD card or external partition. If this option is turned off with --resizeRootFS- the root partition will be created with the same size the original image has. This option has no effect if option -P was used during backup.

Yes
--updateUUIDs  Available with release 0.6.5: When a backup is restore the original PARTUUIDs and LABELs are restored. This usually creates issues when the restored system is mounted on the original system. Use this option to generate new PARTUUIDs during restore. Aus
-g Display the restore progress  
-0 No partition layout will be created on SD card and the existing layout will be reused. See FAQ #6 for details. Off
-1 Partition layout will be created on SD card by by using the layout of the original SD card and ignoring any errors reported including SD size incompatibilities. See FAQ #6 for details.
Note: This may cause unexpected results. Use only if you know what you're doing.
Off

 

 

Restorescenario for Windows- and Macusers

For DD backups the Windows32DiskImager can be used to restore the backup. As an alternative every backup can be restored with Raspberry Pi. TAR or RSYNC backups have to be restored with Raspberry Pi. Following steps are required:

1) Start raspbian on Raspberry

2) Connect the SD cardreader with the SD card

3) Connect the device which holds the backup (e.g. a disk) and mount it or mount a network drive which holds the backup

4) If there is a root partition to restore connact another disk which will get the restored root partition.

Usually the SD card becomes /dev/sda, the backup partition becomes /dev/sdbx and the rootpartition becomes /dev/sdcx. If there is a network device used the root parition usually becomes /dev/sdbx

The actual device allocation may be different and should be checked all the time with

sudo parted -l 

to make sure there will be no other partition overwritten by error.

 

Restorescenario for Linuxusers

That's in general the same as for Windows- and Macusers. In contrast there is no Raspberry Pi required. Just connect the SD card reader on the Linux system together with the backup partition and an optional external root filesystempartition.
 

Examples for restore commands

Required hardware for restore:

1) Running Raspberry Pi running raspbian or another Linux operatingsystem or another LInux system with installed raspiBackup

2) Connected card reader with a new SD card

3) Connected device which keeps the backup (USB or net)

4) If an external rootpartition should be restored there has to be another USB disk or SD card connected

 

Restore boot and root partition to SD card

  1. Name of system to restore is raspberrypi
  2. SD card which will get the restored boot- and root partition is available in the sample command as sdf. The whole SD card will be repartitioned and all old data will be deleted.
  3. Backup to restore is available on /remote/raspifix/disks/backup/rsync/raspberrypi/aspberrypi-rsync-backup-20141230-213032/
  4. Here you will find instruction how to identify the parameters for -d.
sudo raspiBackup.sh -d /dev/sdf /remote/raspifix/disks/backup/rsync/raspberrypi/raspberrypi-rsync-backup-20141230-213032/

 

Restore the boot partition to SD card and the root partition to an external partition 

  1. Name of system to restore is raspberrypi
  2. A partition /dev/sda1 on /dev/sda was already created. It's not required to format the partition.
  3. SD card which will get the restored boot partition is available as sdf in the sample command. Note: All data on the SD card will be deleted.
  4. The root partition will be restored in the sample command to /dev/sda1. Note: All data on the partition will be deleted.
  5. Backup to restore is available on /remote/raspifix/disks/backup/rsync/raspberrypi/raspberrypi/-rsync-backup-20141230-213032/
  6. Here you will find instruction  how to identify the parameters for -d and -R

sudo raspiBackup.sh -d /dev/sdf -R /dev/sda1 /remote/raspifix/disks/backup/rsync/raspberrypi/raspberrypi-rsync-backup-20141230-213032/ 

 

Restore boot and root partition to USB disk (USB boot mode)

  1. Name of system to restore is raspberrypi
  2. USB disk which will get the restored boot- and root partition is available in the sample command as sdf. The whole USB disk will be repartitioned and all old data will be deleted.
  3. Backup to restore is available on /remote/raspifix/disks/backup/rsync/raspberrypi/aspberrypi-rsync-backup-20141230-213032/
  4. Here you will find instruction how to identify the parameters for -d.
sudo raspiBackup.sh -d /dev/sdf /remote/raspifix/disks/backup/rsync/raspberrypi/raspberrypi-rsync-backup-20141230-213032/

  

How do identify the devicenames used by the external SD card and external disk?

Type following command on Raspberry:

fdisk -l | egrep "^Disk /|^/dev"

The output will look similar to

pi@raspberrypi:~# sudo fdisk -l | egrep "^Disk /|^/dev"
Disk /dev/mmcblk0: 8011 MB, 8011120640 bytes
/dev/mmcblk0p1            8192      122879       57344    c  W95 FAT32 (LBA)
/dev/mmcblk0p2          122880    15646719     7761920   83  Linux
Disk /dev/sda: 15.5 GB, 15548284928 bytes
Disk /dev/sdb: 300.1 GB, 300069052416 bytes
/dev/sdb1               1   586072367   293036183+  ee  GPT

You now can see the internal SD card /dev/mmcblk0 with 8GB, the new external SD card /dev/sda with 16GB and the external disk /dev/sdb with 300 GB which has one partition /dev/sdb1 for the external rootpartition.

Given this use -d /dev/sda (External SD card). If the backup also has an external root partition use in addition -R /dev/sdb1 (External rootpartition). Adapt these parameters to your local environment.

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.