In this article, I will try to describe some basic fsarchiver operations only.
We will backup and restore entire partitions. Fsarchiver may also backup and restore selected folders but it is not described here.
The basic syntax is:
fsarchiver operation switches backup-filename what-to-backup-or-restore
fsarchiver is the command itself
operation is usually one of the three:
- savefs creates a backup
- restfs restores a backup
- archinfo shows the info about a backup
switches generally used:
- -v be verbose
- -j5 creates 5 (de)compression threads on multicore CPUs; more threads, faster backups
- -z7 use the 7th level of compression; it goes from 0 to 9; higher the compression, slower the backup
backup-filename the backup file to be created | restored. May be placed anywhere in the file system.
what-to-backup-or-restore the list of target partitions (or folders) to backup, or the list of destionation partitions where backed up partitions must be restored to
Let’s see a practical example. My computer has two internal hard disks, sda and sdb.
This is sda layout:
sda1 contains Gnome3, partition’s label is asg (Antergos Stable Gnome3)
sda2 contains Mate, partition’s label is asm (Antergos Stable Mate)
sda3 contains Cinnamon, partition’s label is asc (Antergos Stable Cinnamon)
sda4 contains Plasma, partition’s label is asp (Antergos Stable Plasma)
All my Linux partitions are always 20G in size. An average Linux installation occupies from 5G to 15G. My data files are kept in the huge separate data partitions, from 500G to 1T each.
All four Antergos partitions are not mounted, so we can work with them, backup or restore. An external USB disk is automatically mounted under /run/media/just folder.
Let's backup all four Antergos partitions - from sda1 to sda4 to the external USB disk.
I usually name backups following this scheme:
compname is the computer’s name I’m backing up
backdate the date of backup
backtime the time of backup
backparts partitions labels being backed up
distroname the name of the distro being backed up
comment a very brief note | comment about the backup
The command to backup four Antergos Linux partitions onto the external USB disk is:
sudo ionice fsarchiver savefs -v -j5 -z7 /run/media/just/alexboss-20170410-1200-sda1to4only-asg-asm-asc-asp-antergos174-example4forum /dev/sda1 /dev/sda2 /dev/sda3 /dev/sda4 && sync
sudo must be used for fsarchiver
ionice keeps GUI fluid during heavy disk I/O operations
sync synces all disks writes, so USB may be safely detached once the backup is finished
The command to restore four Antergos Linux partitions from the external USB disk to their original paritions is:
sudo ionice fsarchiver restfs -v -j5 /run/media/just/alexboss-20170410-1200-sda1to4only-asg-asm-asc-asp-antergos174-example4forum.fsa id=0,dest=/dev/sda1 id=1,dest=/dev/sda2 id=2,dest=/dev/sda3 id=3,dest=/dev/sda4 && sync
The best of fsarchiver is the fact that a backup may be restored not only to original partition(s) but into any partition we want, on the same computer or another. I shift 4 original partitions by 4 toward the end of the disk. From sda1-4 to sda12-15:
sudo ionice fsarchiver restfs -v -j5 /run/media/just/alexboss-20170410-1200-sda1to4only-asg-asm-asc-asp-antergos174-example4forum.fsa id=0,dest=/dev/sda12 id=1,dest=/dev/sda13 id=2,dest=/dev/sda114 id=3,dest=/dev/sda15 && sync
We can also restore only some partition(s) from a backup. Let's restore Antergos Mate and Plasma only, into sda11 and sda12:
sudo ionice fsarchiver restfs -v -j5 /run/media/just/alexboss-20170410-1200-sda1to4only-asg-asm-asc-asp-antergos174-example4forum.fsa id=1,dest=/dev/sda11 id=3,dest=/dev/sda12 && sync
Destination partitions may be of any size, they don’t have to be of the same size as backed up partitions, may be smaller or larger. Destination partitions must only be large enough to hold all files, stored in the backup.
In this example destination parts may go from something about 10G up to 9(9)Z.
If you did not follow my naming scheme and forgot what partitions were backed up, their labels, how much disk space is effectively used within each partition, backup date? No problem, let’s get archive’s info:
fsarchiver archinfo /run/media/just/alexboss-20170410-1200-sda1to4only-asg-asm-asc-asp-antergos174-example4forum.fsa
In my computer, four partitions are backed up in 30-45 minutes. One partition is restored in 3-5 minutes. All four are restored in 12-15 minutes.
You can get more info using --help switch or in fsarchiver man page: