0

How to backup my RPI and keep it up to date without needing to create an image with dd. I want to do it from a linux machine via ssh.

With the backup I want to be able

1) to restore the system on the same sd-card

2) to create a new card when the old one is broken

Those instructions did not work for me with a new card.

jake
  • 1,367
  • 1
  • 11
  • 23

2 Answers2

3

There is an inherent problem with your live backup approach: you need the entire file system to remain stable during the backup process, otherwise there is no way to guarantee that the backup will correctly work afterwards.

One solution is to remount your filesystem read-only during the backup process (pretty much impossible for / on a running system, realistically, you'd have to setup / to be readonly from the start). At which point you might as well use dd and backup the entire image. Another solution is to use LVM or a similar technology that supports snapshots.

Any solution which doesn't freeze the content you're trying to backup may work in some cases, but there will always be an edge case where it will fail. It's not necessarily the problem you're facing now, but I urge you to consider this fundamental issue before you spend more time on this live backup approach.

Dmitry Grigoryev
  • 28,277
  • 6
  • 54
  • 147
1

The instructions you referenced make a copy (of the relevant parts) of the files on the root partition. To make a copy of an OS you ALSO need to copy the files on the boot partition AND the partition table (or be able to re-construct one with the right settings).

Your earlier attempt failed because you only restored part of the image.

In order to restore to the same SD Card it MUST already have the same kernel/firmware - OR you need to have made a copy of the boot files. My restorations have usually been to recover from operator error.

If copying to a new SD Card it needs to be partitioned and formatted FIRST any you need to modify PARTUUID entries in BOTH /etc/fstab and /boot/cmdline.txt to match your SD Card.

The above are not difficult, but there are quite a few steps.

I regularly create SD Card images (to use as security backup) particularly before major updates - although I rarely use the images. See Clone Raspberry Pi SDCard to file on Mac OS X? (this is macOS specific - there are plenty of examples for other OS) On the few occasions when I have to restore this is simple - and I can go back to historic backups if necessary.

I also use rsync to backup files to disk See Can a Raspberry Pi be used to create a backup of itself? These are mainly used to restore specific files. I also use rsync to synchronise SD Card images.

PS SD Cards rarely break. I have only had 3 or 4 corrupted cards with 16 cards and too many Pi over more than 6 years and only a single failure.

Milliways
  • 62,573
  • 32
  • 113
  • 225