Skip to content

Instantly share code, notes, and snippets.

@foursixnine
Forked from gnuyoga/backup_with_fsarchiver.sh
Created August 29, 2014 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save foursixnine/1eca93010c58d56d90dd to your computer and use it in GitHub Desktop.
Save foursixnine/1eca93010c58d56d90dd to your computer and use it in GitHub Desktop.
# install fsarchiver
# In Fedora/RedHat system's :: yum install fsarchiver sfdisk dd
# In Debian/Ubuntu System :: apt-get install fsarchiver sfdisk dd
DEVICE_TO_BACKUP=/dev/sdb # assuming /dev/sda is where you have booted ur primary OS
mkdir ./backup_with_fsarchiver # create a directory
cd ./backup_with_fsarchiver # enter into newly created directory
# only get the first 512 bytes # read mbr in wiki for more details
dd if=$DEVICE_TO_BACKUP of=mbr count=1 bs=512
sfdisk -d $DEVICE_TO_BACKUP > partition.sfdisk
# for partition which are installed on a physcial device
fsarchiver savefs PARTITON_IDENTIFIER.fsa ${DEVICE_TO_BACKUP}/{1,2,3,4...etc}
# for partition which are installed on a physcial device
fsarchiver savefs PARTITON_IDENTIFIER.fsa /dev/VOLUME_GROUP_NAME/VOLUME_NAME
Boot Info Script 0.60 from 17 May 2011
============================= Boot Info Summary: ===============================
=> Grub Legacy0.97 is installed in the MBR of /dev/sda and looks at sector
32636 on boot drive #1 for the stage2 file. A stage2 file is at this
location on /dev/sda. Stage2 looks on partition #1 for /grub/grub.conf..
sda1: __________________________________________________________________________
File system: ext4
Boot sector type: -
Boot sector info:
Operating System:
Boot files: /grub/menu.lst /grub/grub.conf
No arguments provided, cannot continue
====> fsarchiver version 0.6.11 (2010-12-01) - http://www.fsarchiver.org <====
Distributed under the GPL v2 license (GNU General Public License v2).
* usage: fsarchiver [<options>] <command> <archive> [<part1> [<part2> [...]]]
<commands>
* savefs: save filesystems to an archive file (backup a partition to a file)
* restfs: restore filesystems from an archive (overwrites the existing data)
* savedir: save directories to the archive (similar to a compressed tarball)
* restdir: restore data from an archive which is not based on a filesystem
* archinfo: show information about an existing archive file and its contents
* probe [detailed]: show list of filesystems detected on the disks
<options>
-o: overwrite the archive if it already exists instead of failing
-v: verbose mode (can be used several times to increase the level of details)
-d: debug mode (can be used several times to increase the level of details)
-A: allow to save a filesystem which is mounted in read-write (live backup)
-a: allow running savefs when partition mounted without the acl/xattr options
-e <pattern>: exclude files and directories that match that pattern
-L <label>: set the label of the archive (comment about the contents)
-z <level>: compression level from 1 (very fast) to 9 (very good) default=3
-s <mbsize>: split the archive into several files of <mbsize> megabytes each
-j <count>: create more than one compression thread. useful on multi-core cpu
-c <password>: encrypt/decrypt data in archive, "-c -" for interactive password
-h: show help and information about how to use fsarchiver with examples
-V: show program version and exit
<information>
* Support included for: lzo=yes, lzma=yes
* support for ntfs filesystems is unstable: don't use it for production.
#just ensure you select the right 'x'. "fdisk -l" can show connected disks
DEVICE_TO_RESTORE=/dev/sdx
dd if=mbr of=$DEVICE_TO_RESTORE
sfdisk -L $DEVICE_TO_RESTORE < partition.sfdisk
fsarchiver restfs PARTITON_IDENTIFIER.fsa id=0,dest=${DEVICE_TO_RESTORE}{1,2,3,4…}
# based on partition type, if its volume based or normal partition u need to use pvcreate
# pvcreate
# vgcreate
# lvcreate
# partition table of /dev/sdb
unit: sectors
/dev/sdb1 : start= 2048, size= 409600, Id=83, bootable
/dev/sdb2 : start= 411648, size= 7495680, Id=8e
/dev/sdb3 : start= 0, size= 0, Id= 0
/dev/sdb4 : start= 0, size= 0, Id= 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment