Bewertung: 5 / 5

Stern aktivStern aktivStern aktivStern aktivStern aktiv
 

Sometimes you don't want to restore a whole system but restore only some files or directories. That's not directly supported by raspiBackup. But given the fact raspiBackup was designed to restore a system from it's backups with plain Linux tools it's possible for all three backup types. But all activities have to be done on a Linux system because the tools used to retrieve the data are Linux tools. The most convenient way to retrieve backup data is offered by rsync. dd and tar require to execute some commands in the command line first.

 

dd backup

First of all you have to make the img file from the backup available. In the following example the USB disk partition is /dev/sda1 and it's mounted on /mnt read only with

sudo mount -o ro /dev/sda1 /mnt

. Next you have to query the sector offset of the partition you want to mount with fdisk. It's 8192 for the first partition and 122880 for the second partition.

sudo fdisk -l raspberrypi-dd-backup-20160415-222900.img
Disk raspberrypi-dd-backup-20160415-222900.img: 7.5 GiB, 8011120640 bytes, 15646720 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000798a3

Device                                     Boot Start  End      Sectors  Size Id Type
raspberrypi-dd-backup-20160415-222900.img1      8192   122879   114688   56M   c W95 FAT32 (LBA)
raspberrypi-dd-backup-20160415-222900.img2      122880 15646719 15523840 7.4G 83 Linux

Now mount the partition, in this example it's the second one, the root partition, on /media with following command (Note: Use the sector size of your partition and multiply it by 512.)

pi@buster-lite:/mnt/backups/raspberrypi/raspberrypi-dd-backup-20160415-222900 $ sudo mount -o ro,norecovery,loop,offset=$((122880*512)) raspberrypi-dd-backup-20160415-222900.img /media

Now you can access all data from the root partition of your backup in /media :-)

pi@buster-lite:/mnt/backups/raspberrypi/raspberrypi-dd-backup-20160415-222900 $ ls /media/
backup boot dev home lost+found mnt proc root sbin srv tmp var
bin boot.bak etc lib media opt remote run selinux sys usr

Finally cleanup with

sudo umount /media

 

tar backup

First of all you have to make the tar file from the backup available. In the following example the USB disk partition is /dev/sda1 and it's mounted read only on /mnt.

sudo mount -o ro /dev/sda1 /mnt

Let's assume you want to retrieve the whole /etc directory now then execute the following command - but be patient - it will take some time depending on the size of your tar file.

pi@buster-lite:/mnt/backups/raspberrypi/raspberrypi-tar-backup-20171028-205746 $ tar -xf raspberrypi-tar-backup-20171028-205746.tar -C /tmp etc

which will restore the etc directory to /tmp. Now you can access the extracted files.

 

rsync backup

First of all you have to make the rsync backup directory from the backup available. In the following example the USB disk partition is /dev/sda1 and it's mounted read only on /mnt.

sudo mount -o ro /dev/sda1 /mnt

The just access the files inside the backup .

pi@buster-lite:/mnt/backups/raspberrypi/raspberrypi-rsync-backup-20160705-212724-8G $ ls -la
total 57592
drwxr-xr-x 26  pi   pi       4096 Jul 5 2016 .
drwxr-xr-x 14  root root     4096 Apr 18 2018 ..
drwxr-xr-x 2   root root     4096 Nov 15 2015 backup
drwxr-xr-x 2   root root     4096 May 29 2016 bin
drwxr-xr-x 2   root root     4096 Jan 1 1970 boot
drwxr-xr-x 3   root root     4096 Apr 20 2014 boot.bak
drwxr-xr-x 2   root root     4096 Jul 4 2016 dev
drwxr-xr-x 125 root root    12288 Jul 5 2016 etc
drwxr-xr-x 3   root root     4096 Feb 1 2015 home
drwxr-xr-x 16  root root     4096 May 29 2016 lib
drwx------ 2   root root     4096 Dec 15 2012 lost+found
drwxr-xr-x 2   root root     4096 Jul 3 2016 media
drwxr-xr-x 2   root root     4096 Jan 8 2014 mnt
drwxr-xr-x 3   root root     4096 Mar 1 2015 opt
-rwxr-xr-x 1   pi   pi     126799 Jul 5 2016 pi
dr-xr-xr-x 2   root root     4096 Jan 1 1970 proc
drwx------ 2   root root     4096 Jul 10 2013 .pulse
-rw------- 2   root root      256 Dec 16 2012 .pulse-cookie
-rw-r--r-- 1   root root 58720256 Jul 5 2016 raspberrypi-backup.img
-rw-r--r-- 1   root root      512 Jul 5 2016 raspberrypi-backup.mbr
-rw-r--r-- 1   root root      273 Jul 5 2016 raspberrypi-backup.sfdisk
drwxr-xr-x 4   root root     4096 Aug 15 2013 remote
drwx------ 13  root root     4096 Jul 3 2016 root
drwxr-xr-x 2   root root     4096 Jul 5 2016 run
drwxr-xr-x 2   root root     4096 May 29 2016 sbin
drwxr-xr-x 2   root root     4096 Jun 20 2012 selinux
drwxr-xr-x 3   root root     4096 Mar 7 2014 srv
dr-xr-xr-x 2   root root     4096 Jul 4 2016 sys
drwxrwxrwx 2   root root     4096 Jul 5 2016 tmp
drwxr-xr-x 10  root root     4096 Dec 15 2012 usr
drwxr-xr-x 12  root root     4096 Jul 8 2014 var

Kommentar schreiben

*** Hinweis ***

Kommentare sind erwünscht. Aber um lästige Spamposts abweisen zu können gibt es ein paar Dinge die zu beachten sind:
  1. Kommentare mit dem Text http werden sofort zurückgewiesen mit der Meldung Sie sind nicht berechtigt den Tag zu verwenden. zz
  2. Kommentare werden manuell überprüft und es dauert deshalb in der Regel einen Tag bis sie veröffentlicht werden.