@noobertroon said in System Image Backup:
Haven’t tried to use it yet so not sure if it’s simple.
Everything seems to be difficult before tried for the 1st time. After that it seems pretty simple :) .
My question though is how does the backup work.
I’ll try to describe some basic fsarchiver operations only. We’ll backup | restore entire partitions. Fsarchiver may also backup | restore only a selected folders. 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 I generally use these three:
- -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. This computer has two internal hard disks, sda and sdb. Antergos is installed in:
sda8 contains Gnome3rd, partition’s label is asg = Antergos Stable Gnome3rd
sda9 contains Mate, partition’s label is asm = Antergos Stable Mate
sda10 contains Cinnamon, partition’s label is asc = Antergos Stable Cinnamon
sda11 contains Plasma, partition’s label is asp = Antergos Stable Plasma
All my Linux partitions are always 20G in size. A medium Linux installation occupies from 5G to 15G. My data files are kept in the huge separate data partitions, from 500G to 1T each. The data partition(s) are common to all Linuxes, shared between them. Any file within the data partition may be accessed from any installed Linux, there’s no need to duplicate a file. We’ll not backup the data partition in this example. Only the pure Linux partitions.
I’m currently not in one of these four partitios, which I want to backup. I’m in Arch Mate on sda13 partition. All four Antergos partitions are not mounted, so we can work with them, backup or restore.
I attach an external USB disk. It has AlexStar label, has the alexboss folder (corresponds to the name of this laptop), and is automatically mounted under /run/media/just folder:
└─> ls -lha /run/media/just/AlexStar
drwxr-xr-x 9 just users 4.0K Mar 23 12:46 .
drwxr-x---+ 3 root root 60 Apr 10 08:51 ..
drwxrwxrwx 2 just users 16K Apr 5 09:22 alexaero
drwxrwxrwx 2 just users 4.0K Apr 5 16:56 alexbest
drwxrwxrwx 2 just users 20K Apr 9 13:07 alexboss
drwxrwxrwx 2 just users 4.0K Aug 5 2016 alexcore
drwxrwxrwx 2 just users 4.0K Apr 5 09:25 alexhuge
drwxrwxrwx 2 just users 16K Mar 10 2016 lost+found
drwxrwxrwx 4 just users 4.0K Jul 7 2016 .Trash-1000
-rw-r--r-- 1 just 1001 68M Mar 23 12:38 zim.tar.gz
Folder names correspond to other computers names I’m using. zim.tar.gz is the backup of the world’s best note taking application - venerable Zim.
I want to backup all four Antergos partitions - from sda8 to sda11 - to external USB disk, and place the backup file into the alexboss folder on it.
I usually name backups following the 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; my labels are always exactly 3 chars long
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 AlexStar USB disk is:
sudo ionice fsarchiver savefs -v -j5 -z7 /run/media/just/AlexStar/alexboss/alexboss-20170410-1200-sda8to11only-asg-asm-asc-asp-antergos174-example4forum /dev/sda8 /dev/sda9 /dev/sda10 /dev/sda11 && 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 AlexStar USB disk to theis original paritions is:
sudo ionice fsarchiver restfs -v -j5 /run/media/just/AlexStar/alexboss/alexboss-20170410-1200-sda8to11only-asg-asm-asc-asp-antergos174-example4forum.fsa id=0,dest=/dev/sda8 id=1,dest=/dev/sda9 id=2,dest=/dev/sda10 id=3,dest=/dev/sda11 && 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 sda8-11 to sda12-15:
sudo ionice fsarchiver restfs -v -j5 /run/media/just/AlexStar/alexboss/alexboss-20170410-1200-sda8to11only-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 restore only some partition(s) from a backup. Lets restore Antergos Mate and Plasma only, into sda1 and sda2:
sudo ionice fsarchiver restfs -v -j5 /run/media/just/AlexStar/alexboss/alexboss-20170410-1200-sda8to11only-asg-asm-asc-asp-antergos174-example4forum.fsa id=1,dest=/dev/sda1 id=3,dest=/dev/sda2 && 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 smth about 10G up to 9(9)Z. See below.
You didn’t 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/AlexStar/alexboss/alexboss-20170410-1200-sda8to11only-asg-asm-asc-asp-antergos174-example4forum.fsa
Depending on computer in use, 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.
How large is it and will it fit on the thumb drive or do I need another drive/location to put it?
Let’s continue the example. These are real numbers:
- sda8=20G, asg, real space used = 6,04G Gnome3rd
- sda9=20G, asm, real space used = 6,80G Mate
- sda10=20G, asg, real space used = 6,03G Cinnamon
- sda11=20G, asg, real space used = 8,89G Plasma
Four parts take 80G on the disk. The sum of the space, actually occupied by the files, is about 28G. Plus, the space occupied by ext4 itself, about 4 x 500M = 2G. The archive size is 10G. Fsarchiver has reduced 30G down to 10G. Not bad? Very good.
Is there a good tutorial for doing a backup from start to finish?
I’m not aware of any. Fsarchiver’s –help and man are excellent: