fsarchiver forums
View unanswered posts | View active topics It is currently Wed Nov 26, 2014 9:16 pm



Post new topic Reply to topic  [ 9 posts ] 
 Info on doing a bare metal restore using fsarchiver. 
Author Message

Joined: Wed Jun 22, 2011 9:22 am
Posts: 10
Post Info on doing a bare metal restore using fsarchiver.
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.

Thanks.


Wed Jun 22, 2011 11:55 pm
Profile

Joined: Thu Nov 15, 2012 6:44 pm
Posts: 14
Post Re: Info on doing a bare metal restore using fsarchiver.
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:
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.


Thu Nov 15, 2012 6:56 pm
Profile

Joined: Tue Feb 05, 2013 7:38 pm
Posts: 1
Post Re: Info on doing a bare metal restore using fsarchiver.
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.


Tue Feb 05, 2013 7:45 pm
Profile

Joined: Wed Jun 22, 2011 9:22 am
Posts: 10
Post Re: Info on doing a bare metal restore using fsarchiver.
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.


Wed Feb 06, 2013 2:41 am
Profile

Joined: Thu Nov 15, 2012 6:44 pm
Posts: 14
Post Re: Info on doing a bare metal restore using fsarchiver.
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.


Sun Jul 14, 2013 2:18 am
Profile

Joined: Thu Nov 15, 2012 6:44 pm
Posts: 14
Post Re: Info on doing a bare metal restore using fsarchiver.
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

Backup

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:
# sfdisk -d /dev/sda > /mnt/backup/sda.sfd


Step 3: Backup boot partition using fsarchiver

Code:
# 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:
# 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:
# vgcfgbackup -f /mnt/backup/lvm.conf


Step 6: Backup LVM PV UUIDs

For each PV:
Code:
# 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.



Restore

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:
# sfdisk /dev/sda < /mnt/backup/sda.sfd


Step 2: Restore boot partition

Code:
# 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:
# 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:
# vgcfgrestore -f /mnt/backup/lvm.conf <vg name>


Step 5: Re-scan LVM

Code:
# vgscan
# lvscan


Step 6: Mark volume group as available

Code:
# vgchange -a y <vg name>


Step 7: Restore each logical volume

Code:
# 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:
# mkswap /dev/<vg name>/<lv name>


Step 9: Re-install GRUB bootloader in MBR.

Code:
# 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.


Mon Jul 15, 2013 12:03 am
Profile

Joined: Sat Oct 11, 2014 10:49 am
Posts: 1
Post Re: Info on doing a bare metal restore using fsarchiver.
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.


Sat Oct 11, 2014 10:50 am
Profile

Joined: Thu Nov 15, 2012 6:44 pm
Posts: 14
Post Re: Info on doing a bare metal restore using fsarchiver.
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).


Sat Oct 11, 2014 4:01 pm
Profile

Joined: Sun Nov 15, 2009 1:08 pm
Posts: 51
Location: Moscow, Russia
Post Re: Info on doing a bare metal restore using fsarchiver.
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. http://www.fsarchiver.org/Live-backup


Sat Oct 11, 2014 7:16 pm
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.