INTRODUCTION
If you use the Backup plugin (openmediavault-backup) you might have asked: if something goes wrong, how should I restore it?
After all, backup is useless if you don’t know what to do with it, so let’s sort it out!
The Backup plugin offers many backup options, but in this guide, I will be considering fsarchiver, because it’s the one I use and the most convenient: does not waste space and it’s faster than dd (just my 2 cents here, dd team don’t yell at me!). Well, actually the best option would be borgbackup, but it’s very complex and my previous attempts have failed.
CREDITS
Thanks to ryecoaaron for maintaining this plugin.
Thanks to bvrulez for the original guide which was a great resource to start with.
PRE-REQUISITES
Please note this guide only applies to x86/64 systems and not to ARM, like RPi.
You should:
- Configure the Backup plugin using the fsarchiver option
- Run at least one backup
- Recommendation: do not store your backup on a RAID array. It’s harder to mount during an emergency. If you have an SSD for apps, downloads or cache, store it there.
- Recommendation: also copy your backups to another server o a cloud service. Use rclone to automate this activity.
- Check if you’re running a UEFI installation. Run this command in the terminal ls /sys/firmware/efi
If the folder exists, you’re running a UEFI Installation, which means you’ll have to restore an additional partition, which is backed up by the plugin. - Have a spare USB drive to boot SystemRescue live image. It’s a great live image to restore our system.
- Have a spare bootable media in case yours has gone rotten, may happen with USB drives.
WHAT BACKUP FILES MEAN
backup-omv-xxx.blkid - This is the output of blkidput in a file for informational purposes.
backup-omv-xxx.espdd.gz - This is the UEFI (also called ESP) partition, in a compressed archive.
backup-omv-xxx.fdisk - This is the output of fdisk -l put in a file for informational purposes.
backup-omv-xxx.fsa - This is the fsarchiver file containing the OMV system backup.
backup-omv-xxx.grub - This is the first 446 bytes of the disk where grub is installed
backup-omv-xxx.grubparts - This is the first 512 bytes of the disk where grub is installed and the partition table.
backup-omv-xxx.packages - This is the output ofdpkg -l | grep openmediavault put in a file for informational purposes.
RESTORE
Your system doesn’t boot to OMV anymore. Does not matter if GRUB, the OS or the drive are broken, we can handle this.
If you have done your homework, don’t panic!
Plug a keyboard, mouse, monitor and the SystemRescue boot media to your server.
NOTE: If you don't want or you can't do this, you can still perform the restore procedure on a computer or VM, booting SystemRescue. You will need access to your backups, that's why uploading them to another server/cloud is a good idea.
Set your preferred keyboard layout by typing setkmap, then start the graphical environment by typing startx. Whilst you could do everything in SSH/shell, I think it’s better to have a GUI, especially for this kind of task.
Open Gparted and find the OMV boot drive. Format it to ensure nothing dirty is left behind. Select the system drive, then navigate to Device > Create Partition Table.
- If you’re using UEFI, select GPT
- If you’re not using UEFI (legacy boot), select ms-dos
If the drive refuses to be formatted, the drive is broken and you’ll have to plug in a new one.
Open a terminal and type lsblk. Write down the name of the new system drive and the partition where the backup is located. If your backup is on an external drive, connect the drive and type the command again.
Create a new folder where to mount the backups. Run mkdir /mnt/backup, or wathever you like under /mnt.
Mount the partition that contains the backup in the folder you just created. It should be something like /sdXN, where X is a letter (related to the drive) and N is a number (related to the partition).
Ensure the mount is successful. Run ls /mnt/backup, you should see familiar names. If not, run umount /mnt/backup and repeat the process with another disk.
Locate the backup folder. Example: /mnt/backup/omvbackup/
RESTORE THE PARTITION TABLE
Let's kick off by restoring the grubparts file. This is the first 512 bytes of the disk where grub is installed and the partition table.
Note that:
- sdX is the new system drive - don't add the partition number. In my case is sda
- In this example backups are located in /mnt/backup/omvbackup/ - use the tab to autocomplete in the backup folder. xxx is the timestamp of the backup. Select the grubparts file
dd if=/mnt/backup/omvbackup/backup-xxx.grubparts of=/dev/sdN bs=512
If restore was successful, refresh Gparted and will show your partitions. Ignore the "Used" column, it doesn't reflect the current state (they're all empty).
Identify the boot and system partitions, you'll need these for the next steps. Write down their full name.
RESTORE UEFI PARTITION
If your system does not have UEFI, skip this section.
Decompress the UEFI partition contained in the file espdd.gz.
The partition will be extracted to a file ending with .espdd, which should be around 512 MB.
Check with GParted which is the boot partition, usually the first (number 1). Has a boot flag.
Note that:
- sdN1 is usually your boot partition – when running the command, enter the partition number after the letter.
- Select the .espdd file in the backup folder
dd if=/mnt/backup/omvbackup/backup-xxx.espdd of=/dev/sdN1 bs=512
RESTORE SYSTEM PARTITION
Check with GParted which is the system partition, usually the largest.
- sdX2 is usually your system partition - when running the command, enter the partition number after the letter.
- Select the .fsa file in the backup folder
fsarchiver restfs /mnt/path/to/backup.fsa id=0,dest=/dev/sdX2 -v
This step can take up to 30 minutes when restoring to a USB thumb drive, but the command will show the completion percentage.
When completed, type reboot and the system will reboot. Remove the SystemRescue media.
If you’re done these steps correctly, you have restored your OMV system which will boot just as before
STILL NO BOOT?
If you still cannot boot, it is likely that Grub was not restored successfully. It can happen on some systems with specific or weird configurations, or simply because you're out of luck.
To resolve this problem, reboot to SystemRescue media, and reinstall grub using the utility grub-install. There are many tutorials describing the process, here's one directly from Ubuntu help pages.