Page 1 of 1

Info on doing a bare metal restore using fsarchiver.

Posted: Wed Jun 22, 2011 11:55 pm
by msetzerii
I've been the maintainer for the g4l project for many years.
It had partimage before I took over, but have recently added the fsarchiver as an options as well.
I have not implemented all the options, but have it so it can do partition backups, and one can select
compression options.
I've also been able to backup LVM partitions using it as the /dev/dm? directories.

In a simple test, I backed up the LVM partition of 250GB and it took about 25 minutes to backup using
fsarchjver compared to the dd backup that takes about 1 hour 40 minutes. The space used on the / is only
about 40GB, so fsarchivers file level backup doesn't have to deal with the unused space.

The difference is that a full disk backup using g4l would restore all the partitions, LVM, mbr and partition table.
I could also restore the mbr and partition table using the MBR options of g4l, and then restore the LVM, which
would include the include the / and swap partitions of the LVM.

I'm looking at adding options to be able to do a bare metal type restore, but the issue would be recreating the LVM setup.
The MBR backup would create the physical partitions, and I think the vgcfgbackup and vgcfgrestore could be used to
resetup the LVM, but I have not done a test of this? Don't know if fsarchiver could backup the swap partitions, or if it would
be worth it. If not come up with a way to recreate the swap LVM partition.

Don't know if others have done something like this, or could provide some suggestions.


Re: Info on doing a bare metal restore using fsarchiver.

Posted: Thu Nov 15, 2012 6:56 pm
by Berix
EDIT: I understand I'm replying to an old topic, but I wanted to get this information out there in case it can help someone else.

I've been doing some work on this for my job. We're transitioning our customers from their IBM AIX servers onto RedHat Linux servers, mainly because of price. The nice thing about AIX is that they have a "mksysb" which does a complete restoreable system backup to a tape drive.

What I've been trying to do is something similar for Linux and FSArchiver is the closest I can get.

Here's my basic process:

1) Backup the partition tables using sfdisk

2) Backup the boot partition (which is outside of LVM) using fsarchiver, with the -A option

3) Backup all of the logical volumes using the snapshot feature

4) Backup the LVM configuration using vgcfgbackup

5) Either backup the LVM physical volume information separately or just reference the config file from step 4.

Then, when I go to do a restore:

1) Restore partition tables using sfdisk

2) Restore the boot partition using fsarchiver

3) Re-create swap filesystem if necessary (by just using mkswap)

(and here's the tricky part)
4) Re-create the physical volume(s) using pvcreate, specifying the same UUID as before.

Code: Select all

pvcreate --restorefile lvmbackup.conf --uuid "Pirpip-wgVD-3AOv-gwVe-FJWN-yGR6-7Qs7Sp"
5) Restore the LVM configuration using vgcfgrestore

6) Bring volume group back up using vgchange -a y /dev/<vg name>

7) Restore logical volumes using fsarchiver

8) Since I'm not backing up the MBR, at this point I would mount all of my partitions and chroot into them so I can re-install grub, because restoring the MBR always seems to be a little flaky for me. From my experiences, GRUB seems to reference individual sector numbers, and if any of these gets restored different, restoring the MBR just flat isn't going to work. This is why I do a manual grub install.

Using these methods, I have completely backed up an entire system, while it was running, shut it down, swap hard drives, and restored it to a new hard drive. The system booted back up like nothing ever happened.

Let me know if you have any questions or if anything seems unclear. I've been through so many different trials and tribulations related to getting these backups working, so I may have made a mistake somewhere.

Re: Info on doing a bare metal restore using fsarchiver.

Posted: Tue Feb 05, 2013 7:45 pm
by bayardk
Your guidelines are very helpful, but your post would become downright invaluable if you could fill out actual command sequences and parameters. I understand that fsarchiver forum members might know how to fill in the blanks, but I came here from Google looking for a bare metal LVM backup/restore solution. It's frustrating to have the outline in front of me, but not know how to implement the details. I think a detailed example would earn many hits. The few examples I've found so far on the 'net do not work. Thanks, whatever you decide.

Re: Info on doing a bare metal restore using fsarchiver.

Posted: Wed Feb 06, 2013 2:41 am
by msetzerii
Just a quick question? Why not just backup the disk as a one step process?
That would include the mbr, partitions, and everything for a true bare metal backup.
The only issue is that it does take a bit more time and size if you don't clear the unused space.

I maintain the g4l project that does this type of backup, and it includes fsarchiver for other options,
but I have only used it a few times.

Concerning the size issue, I once did an image of a fresh install of Fedora Core 3 on an 80GB disk,
and the image created was 12GB. I then cleared the free space on the partitions, and redid the image,
and it was only 2.5G.

In the raw mode, it is used dd to read the sectors, and then compress them to an image file, so it is
an all backup process for the disk or partitions.

Re: Info on doing a bare metal restore using fsarchiver.

Posted: Sun Jul 14, 2013 2:18 am
by Berix
How exactly would you do the backup of the full disk (mbr, partitions, etc.) on a live running system using g4l (sorry, I'm not familiar with g4l).

Also, I'll try to get some instructions/commands together for how I'm doing a bare-metal backup and restore using fsarchiver. It is a manual process, but it works and is pretty simple once you get all of the steps down.

Re: Info on doing a bare metal restore using fsarchiver.

Posted: Mon Jul 15, 2013 12:03 am
by Berix
Here are some instructions that should get you a bare-metal backup and recovery. In my example, I'm backing up and recovering a CentOS system using a USB drive for the backup. This example also requires that you use LVM


Step 1: Find a place to store your backup.

In my examples, I'm using a USB hard drive mounted in /mnt/backup

Step 2: Backup partition tables using sfdisk

Code: Select all

# sfdisk -d /dev/sda > /mnt/backup/sda.sfd
Step 3: Backup boot partition using fsarchiver

Code: Select all

# fsarchiver -A -o savefs /mnt/backup/boot.fsa /dev/sda1
Step 4: Backup logical volumes using LVM snapshots and fsarchiver

For each logical volume:

Code: Select all

# lvcreate -s /dev/<vg name>/<lv name> -n snap_lv -L <size>
# fsarchiver -o savefs /mnt/backup/<lv name>.fsa /dev/<vg name>/snap_lv
# lvremove -f /dev/<vg name>/snap_lv
This will create a new shapshot logical volume based on the one you want to backup. The <size> needs to be at least as large as the logical volume you're backing up. Once we run the backup, we remove the snapshot LV.

Step 5: Backup LVM configuration

Code: Select all

# vgcfgbackup -f /mnt/backup/lvm.conf
Step 6: Backup LVM PV UUIDs

For each PV:

Code: Select all

# pvdisplay /dev/<path>
This will print out information about the physical volume. You'll want to grab the UUID and store it in a text file along with the rest of your backup.


For the restore, I use SystemRescueCD. Boot up and make sure your backup drive is mounted and accessible. In my example, the drive is mounted in /mnt/backup

Step 1: Restore partition tables

Code: Select all

# sfdisk /dev/sda < /mnt/backup/sda.sfd
Step 2: Restore boot partition

Code: Select all

# fsarchiver restfs /mnt/backup/boot.fsa id=0,dest=/dev/sda1
Step 3: Re-create physical volumes, using the PV UUID from your PV text file.

Code: Select all

# pvcreate --uuid "<paste UUID here>" --restorefile /mnt/backup/lvm.conf /dev/sda2
You'll want to of course subsitute /dev/sda2 with the path to your PV partition.

Step 4: Restore VG configuration

Code: Select all

# vgcfgrestore -f /mnt/backup/lvm.conf <vg name>
Step 5: Re-scan LVM

Code: Select all

# vgscan
# lvscan
Step 6: Mark volume group as available

Code: Select all

# vgchange -a y <vg name>
Step 7: Restore each logical volume

Code: Select all

# fsarchiver restfs /mnt/backup/<filename>.fsa id=0,dest=/dev/<vg name>/<lv name>
Step 8: Re-create swap filesystem (this step may vary, based on where your swap is)

Code: Select all

# mkswap /dev/<vg name>/<lv name>
Step 9: Re-install GRUB bootloader in MBR.

Code: Select all

# mkdir /mnt/linux
# mount /dev/<vg name>/<lv name> /mnt/linux                        <-- this should be your root filesystem
# mount -o bind /proc /mnt/linux/proc
# mount -o bind /dev /mnt/linux/dev
# mount -o bind /sys /mnt/linux/sys
# chroot /mnt/linux /bin/bash
# mount /dev/sda1 /boot/                                        <-- this should be your boot partition
# grub-install /dev/sda
# exit
# umount /mnt/linux/{dev,proc,sys,boot}
# umount /mnt/linux/
Step 10: Complete

You can now reboot and boot from your recovered system.

I've been through this process several times and it seems to work great so far.

Re: Info on doing a bare metal restore using fsarchiver.

Posted: Sat Oct 11, 2014 10:50 am
by raima55
I launch FSArchiver (fsarchiver savefs -j4 /mnt/SATA1/disk2.fsa /dev/sdb1), I get the message which explains that sdb1 is mounted in read-write option, and FSArchiver is stopped.

Re: Info on doing a bare metal restore using fsarchiver.

Posted: Sat Oct 11, 2014 4:01 pm
by Berix
In order to back up a partition that's still mounted, you have to use the -A option in fsarchiver (forces it to continue and ignore the mount warning).

Re: Info on doing a bare metal restore using fsarchiver.

Posted: Sat Oct 11, 2014 7:16 pm
by Lazy_Kent
Berix wrote:In order to back up a partition that's still mounted, you have to use the -A option in fsarchiver (forces it to continue and ignore the mount warning).
'man fsarchiver' describes all the options.
The FSarchiver site provides all the info also.