Guide - Backup and Restore on Raspberry Pi 4B

  • I am new to the scene and OMV and was looking into how to backup and restore the SD card when it fails (or when I destroy my setup with my stupidity inexperience)


    After scavening a lot of forum threads, discussions and some heated arguments, I took it to heart that systems are widely different and hard to generalize backup and restore procedures but I thought to share my setup, in the hope it will help others in their setups...


    There are 2 ways to do the backups (full disk or root partition only) which actually go hand in hand. I will describe both and the reasoning behind it. The OMV backup-plugin can do a backup of the ROOT partition, but not of the BOOT partition. in my hands, Clonezilla and SystemRescue failed to work for me or failed to produce viable drives. An other advantage of using fsarchiver is that drives sizes can be different! it works on the file levels and not on the block levels for backup and restore!


    TEST YOUR BACKUP AND RESTORE PROCEDURE TO VERIFY A VIABLE BACKUP


    my setup:

    - Raspberry Pi 4B with Raspberry Pi OS Lite installed (bookworm, kernel 6.6)

    - activate boot from USB, update boot order in raspi-config to try USB first

    - OMV v7 installed via command line tools as in the user guide here

    - I assume you have a drive attached with a folder for your stuff and backups


    tools needed:

    USB drive with Raspberry Pi OS Lite and fsarchiver installed


    1. Initial backup - BOOT and ROOT partition

    - shut down Raspberry

    - insert USB OS drive and power on

    - ssh into the raspberry using the login from the USB drive setup

    - make sure you booted from the USB drive and that the SD card was not mounted using lsblk

    - mount the drive with your backup folder

    - make sure to identify the SOURCE drives/partitions correctly! (e.g. sda1, sda2)

    - run the command line code of sfarchiver to backup the whole drive to the backup folder; e.g.

    Code
    fsarchiver savefs /mnt/backup_folder/disk_backup_yymmdd.fsa /dev/sda1 /dev/sda2


    after the backup finishes, it gives a short summary and if there were errors during its run


    you can check the archive if it contains 2 filesystems (the 2 partitions) using the code

    Code
    fsarchiver archinfo /mnt/backup_folder/disk_backup_yymmdd.fsa


    2. Restore whole drive to new SD card (and verify successful backup and restore)

    - shut down Raspberry

    - insert USB OS drive and power on

    - ssh into the raspberry using the login from the USB drive setup

    - make sure you booted from the USB drive and that the SD card was not mounted using lsblk

    - mount the drive with your backup folder (SOURCE)

    - check the TARGET drive ID lsblk e.g. sdT

    - using the code below, both partitions can be restored with 1 command line

    Code
    fsarchiver restfs /mnt/backup_folder/disk_backup_yymmdd.fsa id=0,dest=/dev/sdT1 id=1,dest=/dev/sdT2

    !!! power down the Raspberry , change the SD card to the new SD card you just made and start it up to verify a viable restore!!!


    ===


    the following is my plan for future backups after the initial steps, as the BOOT partition shouldn't change afterwards (correct me if I am wrong here).

    I tested the following step once successfully, so I don't see why it should not be possible to do it like this...


    3. Continuous backups

    - activate the backup-plugin in OMV and set it to fsarchiver (remember, only the ROOT partition is backed up from here!)

    - set schedule to run once every... month?

    - change the retention time to a longer time period (ANYTHING OLDER THAN X DAYS IS DELETED)


    - if need to restore: restore the ROOT partition using the steps described in step 2, but with only one destination arguments

  • chente

    Hat das Thema freigeschaltet.
  • ryecoaaron

    Hat das Thema freigeschaltet.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!