Skip to content

About FsArchiver

FSArchiver is a system tool that allows you to save the contents of a file-system to a compressed archive file.

The file-system can be restored on a partition which has a different size and it can be restored on a different file-system. Unlike tar/dar, FSArchiver also creates the file-system when it extracts the data to partitions.

Everything is checksummed in the archive in order to protect the data. If the archive is corrupt, you just loose the current file, not the whole archive.

Installation

As usually we start by installing the package.

# Debian & Ubuntu
apt install -y fsarchiver

# Fedora
dnf install -y fsarchiver

# CentOS / RHEL
# You must install libzstd manually
yum install -y epel-release libzstd && yum update
wget https://github.com/fdupoux/fsarchiver/releases/download/0.8.5/fsarchiver-0.8.5-1.el7.x86_64.rpm
rpm -i fsarchiver-0.8.5-1.el7.x86_64.rpm

# Arch / Manjaro
pacman -Sy fsarchiver

# Suse family
zypper install -y fsarchiver

Basic options

A list of arguments can be used with fsarchiver.

 * usage: fsarchiver [<options>] <command> <archive> [<dev1> [<dev2> [...]]]
<commands>
 * savefs: save filesystems to an archive file (backup a device 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/simple]: 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 to save a filesystem when acls and xattrs are not supported
 -x: enable support for experimental features (they are disabled by default)
 -e <pattern>: exclude files and directories that match that pattern
 -L <label>: set the label of the archive (comment about the contents)
 -z <level>: legacy compression level from 0 (very fast) to 9 (very good)
 -Z <level>: zstd compression level from 1 (very fast) to 22 (very good)
 -s <mbsize>: split the archive into several files of <mbsize> megabytes each
 -j <count>: create more than one (de)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

Little compression benchmark

On fsarchiver you have several choices about the compression level what you want to use as you can see on the list beneath.

LEVEL Equivalent
0 lz4
1 lzo -3
2 gzip -3
3 gzip -6
4 gzip -9
5 bzip2 -2
6 bzip2 -5
7 lzma -1
8 lzma -6
9 lzma -9

The compression format used by fsarchiver can be very important.

To do our test I have create a virtual machine on my hypervisor (Proxmox) with these specs :

  • OS : Debian 9.5
  • CPU : 4vCPU @ 3Ghz
  • RAM : 2Gio
  • /dev/sda1 => /boot
  • /dev/systemdeb/root => /root
  • /dev/systemdeb/var => /var
  • /dev/systemdeb/tmp => /tmp
  • /dev/sdb1 => /mnt/backup
  • Filesystem Host => XFS
  • Filesystem Backup => XFS

The amount of RAW DATA is 2.63Gio.

Level Ram used Compressed Process Time
-z3 70Mio 917Mio 0 min 37 sec
-z6 85Mio 846Mio 0 min 58 sec
-z8 157Mio 761Mio 2 min 49 sec
-z9 230Mio 751Mio 5 min 45 sec
-Z11 90Mio 874Mio 0 min 34 sec
-Z15 105Mio 868Mio 1 min 00 sec
-Z19 110Mio 820Mio 2 min 08 sec
-Z22 140Mio 807Mio 3 min 02 sec

By default if I have the support of ZSTD I use it with -Z11 or -Z19 arguments and if ZSTD isn't available I switch on -z6 or -z8.

Example of uses

Warning

To work with fsarchiver you define the place where is stored your backup.fsa and after the target where do the files come from.

On a mounted filesystem with default compression level.

fsarchiver savefs -o /mnt/save/save-sda2.fsa /dev/sda2 -j4 -v -A

The same but we change the level of the compression with argument -z6.

fsarchiver savefs -o /mnt/save/save-sda2.fsa /dev/sda2 -j4 -v -A -z6

This time we use ZSTD with argument -Z.

Note

On debian Zstd is not curently supported. Is is installed but he don't work.

If you can use ZSTD you have access to 22 level of compression.

fsarchiver savefs -o /mnt/save/save-sda2.fsa /dev/sda2 -j4 -v -A -Z22

On a unmounted filesystem.

fsarchiver savefs -o /mnt/save/save-sda2.fsa /dev/sda2 -j4 -v

With LVM

In case where you use LVM you have access at both way to do your backup. Classic and by using snapshot LVM.

Classic mode

On a mounted filesystem with LVM.

Be sure to identify your logical volume with 'lvdisplay'.

--- Logical volume ---
  LV Path                /dev/systemdeb/swap
  LV Name                swap
  VG Name                systemdeb
  LV UUID                KnTHeC-fDHl-5C7j-the0-zfTg-IByI-rCqPWD
  LV Write Access        read/write
  LV Creation host, time sysresccd, 559220-11-14 14:36:23 +0100
  LV Status              available
  # open                 0
  LV Size                2.00 GiB
  Current LE             512
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:0

  --- Logical volume ---
  LV Path                /dev/systemdeb/tmp
  LV Name                tmp
  VG Name                systemdeb
  LV UUID                QqhJgd-6BIv-sX0k-sA6u-VQHV-WZnb-tdqrEH
  LV Write Access        read/write
  LV Creation host, time sysresccd, 559220-11-14 14:36:48 +0100
  LV Status              available
  # open                 1
  LV Size                5.00 GiB
  Current LE             1280
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:1

  --- Logical volume ---
  LV Path                /dev/systemdeb/root
  LV Name                root
  VG Name                systemdeb
  LV UUID                RrcnYD-XcoL-q4a8-qhY3-ai5u-IeDu-mOQyr1
  LV Write Access        read/write
  LV Creation host, time sysresccd, 559220-11-14 14:37:39 +0100
  LV Status              available
  # open                 1
  LV Size                15.00 GiB
  Current LE             3840
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:2

  --- Logical volume ---
  LV Path                /dev/systemdeb/var
  LV Name                var
  VG Name                systemdeb
  LV UUID                FQI1fG-at1N-JKKe-ZaA7-X1tf-5VSz-IC7Mo5
  LV Write Access        read/write
  LV Creation host, time sysresccd, 559220-11-14 14:38:11 +0100
  LV Status              available
  # open                 1
  LV Size                17.50 GiB
  Current LE             4480
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:3

We save our logical volume called root located under /dev/systemdeb/ as you can see before.

fsarchiver savefs -o /tmp/backup/root-save.fsa /dev/systemdeb/root -j4 -v -A

We can save several logical volume or partitions in the same archive.fsa.

For example, I have this partition structure.

  • /dev/sda1 = /boot EXT2
  • /dev/sda2 = Extended partition
  • /dev/systemdeb/root = / XFS
  • /dev/systemdeb/var = /var XFS
  • /dev/systemdeb/tmp = /tmp XFS

And I want to save all of my partitions in one archive.fsa.

fsarchiver savefs -o /tmp/backup/root-save.fsa /dev/systemdeb/root /dev/systemdeb/var /dev/systemdeb/tmp -j4 -v -A

Now if I explore my archive by typing fsarchiver archinfo /tmp/backup/root-save.fsa I have similar output as beneath.

ArchInfo

We want to restore /var partition on our system. As you can see on the screenshot below var have ID 1 and my futur target is /dev/systemdeb/var.

fsarchiver restfs /tmp/backup/save-root.fsa id=1,dest=/dev/systemdeb/var -j4 -v -A

To see more examples you can type on your terminal fsarchiver --help or man fsarchiver.