My plan was to analyze the source code for Btrbk but that hit a snag when I opened the source and found it to be composed of 7,345 lines of Perl. Perl has the reputation of being easy to write and hard to read. Since I have never learned, or even studied, Perl, analyzing Btrbk is way above my pay grade. From the docs, and and some code snippits it appears that Btrbk is configured to store full snapshots at
which is identical to /mnt/snapshots/@yyyymmdd, and /mnt/snapshots/@homeyyyymmdd.
So, if one wants to automate a process similar to or like the one I use then Btrbk is your tool. Also, Btrbk also has the ability to send & receive snapshots to remote locations, which Snapper cannot do, and I believe that TimeShift can't do that either. Manual commands can do it.
I installed the version of snapper in the 20.04 repository and configured the root (/) with the default configuration.
Here are the folders I created and used to hold snapshots:
Now I view the folders created by Snapper:
As can be seen, I've created 4 snapshots. The 2nd is mmissing because I deleted it.
What's under snapshot 3?
Two files, the info.xml, which contains meta data the user entered when they created the snapshot, AND, the actual snapshot itself, labled "snapshot". Here's the info.xml contents:
What's in snapshot?
My entire system!
What is the size of it?
Yup, it's the whole ball of wax! A complete snapshot.
Knowing this, one could use the "btrfs su snapshot" to create a rw copy of snapshot 3 and name it "@".
Where to put @? It's under the <ROOT_FS> but it cannot be accessed from within /. Remember? You cannot "cd .." from / and move to a higher directory level, which would be <ROOTT_FS>. That's why Snapper does NOT restore by renaming @ (or @home) to @old and creating a new @ from a snapshot. How does Snapper restore to a previous snapshot? By copying one or more (or all) files from a snapshot back into the system using it's "undochange" command. A "complete" restore is done by using just the "snapper undochange x..y" command. When finished the system is back at the condition it was in when it was "x". Changes will NOT include folders and files listed in filter.txt. To undo a specific file you'd use "snapper undochange x..y somefile1 somefile2 ...".
What won't Snapper restore?
And there, in base.txt, is what it won't restore. xll.txt holds "/.Xuathority".
So, say you do "sudo apt update && sudo apt full-upgrade". Snapper creates a "Pre" snapshot before apt runs "full-upgrade" and a "Post" snapshot after the upgrade is done. Say the upgrade borks your system in some way. IF the upgrade did't crash your display and you can still access the command line, you issue
"sudo snapper undochange x..y"
where x is the number of the Pre snapshot and y is the number of the Post snapshot. How do you get x and y?
By doing "sudo snapper list". Then you can use the undochange command.
There has been several times when I've inadvertantly erased a file or folder. Without Snapper's "undochange" comand how do I recover those files? By opening a Konsole, sudo'ing to root, and mounting my drive to /mnt. Then I fire mc and put the most recent snapshot in the left panel and my system in the right panel. I highlight the files/folders I want to restore and copy them from the left panel to the right panel. To roll back the entire system I mv @ to @old and create a rw @ from the most recent snapshot. Then I reboot.
Back in the system I delete @old.
Snapper does NOT backup your system. Neither does making snapshots the way I do. Your system is backed up ONLY when you use the btrfs send & receive commands to move a ro snapshot to a remote drive.
Snapper has a "diff" command. With all of its snapshots residing under / one can use Kdiff3 to view the difference between a folder in a snapshot and the same folder in another snapshot or in your system.
The btrfs send command also has that same ability, but only for entire snapshots.
btrfs send --no-data -p /mnt/snapshots/@202102182239 /mnt/snapshots/@202102192115 > diff.txt
Browse diff.txt to see the differences.
Unlike TimeShift, Snapper does NOT link your <ROOT_FS> to a subdirectory under /, which is dangerous.
Code:
/mnt/btr_backup/mylaptop/rootfs.YYYYMMDD /mnt/btr_backup/mylaptop/home.YYYYMMDD
So, if one wants to automate a process similar to or like the one I use then Btrbk is your tool. Also, Btrbk also has the ability to send & receive snapshots to remote locations, which Snapper cannot do, and I believe that TimeShift can't do that either. Manual commands can do it.
I installed the version of snapper in the 20.04 repository and configured the root (/) with the default configuration.
Here are the folders I created and used to hold snapshots:
Code:
:~# [B]vdir /mnt[/B] total 0 drwxr-xr-x 1 root root 228 Feb 20 01:15 @ drwxr-xr-x 1 root root 130 Mar 16 21:50 snapshots :~# [B]vdir /mnt/snapshots[/B] total 0 drwxr-xr-x 1 root root 208 Feb 20 01:15 @202103122130 drwxr-xr-x 1 root root 208 Feb 20 01:15 @202103132115 drwxr-xr-x 1 root root 208 Feb 20 01:15 @202103142159 drwxr-xr-x 1 root root 208 Feb 20 01:15 @202103152204 drwxr-xr-x 1 root root 208 Feb 20 01:15 @202103162149
Code:
:~# [B]vdir /.snapshots/ [/B] total 0 drwxr-xr-x 1 root root 32 Mar 16 22:00 1 drwxr-xr-x 1 root root 32 Mar 16 22:02 3 drwxr-xr-x 1 root root 60 Mar 16 22:05 4 drwxr-xr-x 1 root root 32 Mar 17 11:05 5
What's under snapshot 3?
Code:
:~#[B] vdir /.snapshots/3 [/B] total 4 -rw------- 1 root root 175 Mar 16 22:02 info.xml drwxr-xr-x 1 root root 228 Feb 20 01:15 [B]snapshot [/B]
Code:
[FONT=monospace][FONT=monospace]:~# [B]cat /.snapshots/3/info.xml [/B] <?xml version="1.0"?> <snapshot> <type>pre</type> <num>3</num> <date>2021-03-17 03:02:59</date> <description>apt</description> <cleanup>number</cleanup> </snapshot> [/FONT] [/FONT]
What's in snapshot?
Code:
:~# [B]vdir /.snapshots/3/snapshot/[/B] total 28 drwxr-xr-x 1 root root 0 Jan 9 2020 backup lrwxrwxrwx 1 root root 7 Jan 5 2020 bin -> usr/bin drwxr-xr-x 1 root root 600 Mar 12 21:32 boot drwxr-xr-x 1 root root 0 Jan 5 2020 cdrom drwxr-xr-x 1 root root 140 Jan 3 2020 dev drwxr-xr-x 1 root root 5338 Mar 16 21:52 etc drwxr-xr-x 1 root root 10 Aug 6 2020 home .... drwxr-xr-x 1 root root 0 Jan 3 2020 srv drwxr-xr-x 1 root root 0 Dec 5 2019 sys drwxrwxrwt 1 root root 1950 Mar 16 22:02 tmp drwxr-xr-x 1 root root 126 Dec 31 13:08 usr drwxr-xr-x 1 root root 120 Feb 20 01:15 var
What is the size of it?
Code:
[FONT=monospace]:~# [B]btrfs fi usage /.snapshots/3/snapshot[/B] Overall: Device size: 465.76GiB Device allocated: 134.03GiB Device unallocated: 331.73GiB Device missing: 0.00B Used: 111.60GiB Free (estimated): 352.90GiB (min: 352.90GiB) Data ratio: 1.00 Metadata ratio: 1.00 Global reserve: 206.77MiB (used: 0.00B) Data,single: Size:131.00GiB, Used:109.83GiB (83.84%) /dev/sda1 131.00GiB Metadata,single: Size:3.00GiB, Used:1.77GiB (59.12%) /dev/sda1 3.00GiB System,single: Size:32.00MiB, Used:16.00KiB (0.05%) /dev/sda1 32.00MiB Unallocated: /dev/sda1 331.73GiB [/FONT]
Knowing this, one could use the "btrfs su snapshot" to create a rw copy of snapshot 3 and name it "@".
Where to put @? It's under the <ROOT_FS> but it cannot be accessed from within /. Remember? You cannot "cd .." from / and move to a higher directory level, which would be <ROOTT_FS>. That's why Snapper does NOT restore by renaming @ (or @home) to @old and creating a new @ from a snapshot. How does Snapper restore to a previous snapshot? By copying one or more (or all) files from a snapshot back into the system using it's "undochange" command. A "complete" restore is done by using just the "snapper undochange x..y" command. When finished the system is back at the condition it was in when it was "x". Changes will NOT include folders and files listed in filter.txt. To undo a specific file you'd use "snapper undochange x..y somefile1 somefile2 ...".
What won't Snapper restore?
Code:
[FONT=monospace][FONT=monospace][FONT=monospace][COLOR=#000000]:[/COLOR][COLOR=#5454ff][B]~[/B][/COLOR][COLOR=#000000]$ [B]vdir /etc/snapper/ [/B][/COLOR] total 0 drwxr-xr-x 1 root root 8 Mar 17 11:12 configs drwxr-xr-x 1 root root 14 Mar 16 21:52 config-templates drwxr-xr-x 1 root root 44 Mar 16 21:52 filters [COLOR=#000000]:[/COLOR][COLOR=#5454ff][B]~[/B][/COLOR][COLOR=#000000]$ [B]vdir /etc/snapper/filters/[/B] [/COLOR] total 12 -rw-r--r-- 1 root root 104 Feb 3 2020 base.txt -rw-r--r-- 1 root root 37 Feb 3 2020 lvm.txt -rw-r--r-- 1 root root 14 Feb 3 2020 x11.txt [COLOR=#000000]:[/COLOR][COLOR=#5454ff][B]~[/B][/COLOR][COLOR=#000000]$ [B]cat /etc/snapper/filters/base.txt [/B][/COLOR] /etc/adjtime /etc/mtab /var/lib/logrotate.status /var/lib/misc/random-seed /var/lib/ntp/drift/ntp.drift [/FONT][/FONT][/FONT]
And there, in base.txt, is what it won't restore. xll.txt holds "/.Xuathority".
So, say you do "sudo apt update && sudo apt full-upgrade". Snapper creates a "Pre" snapshot before apt runs "full-upgrade" and a "Post" snapshot after the upgrade is done. Say the upgrade borks your system in some way. IF the upgrade did't crash your display and you can still access the command line, you issue
"sudo snapper undochange x..y"
where x is the number of the Pre snapshot and y is the number of the Post snapshot. How do you get x and y?
By doing "sudo snapper list". Then you can use the undochange command.
There has been several times when I've inadvertantly erased a file or folder. Without Snapper's "undochange" comand how do I recover those files? By opening a Konsole, sudo'ing to root, and mounting my drive to /mnt. Then I fire mc and put the most recent snapshot in the left panel and my system in the right panel. I highlight the files/folders I want to restore and copy them from the left panel to the right panel. To roll back the entire system I mv @ to @old and create a rw @ from the most recent snapshot. Then I reboot.
Back in the system I delete @old.
Snapper does NOT backup your system. Neither does making snapshots the way I do. Your system is backed up ONLY when you use the btrfs send & receive commands to move a ro snapshot to a remote drive.
Snapper has a "diff" command. With all of its snapshots residing under / one can use Kdiff3 to view the difference between a folder in a snapshot and the same folder in another snapshot or in your system.
The btrfs send command also has that same ability, but only for entire snapshots.
btrfs send --no-data -p /mnt/snapshots/@202102182239 /mnt/snapshots/@202102192115 > diff.txt
Browse diff.txt to see the differences.
Unlike TimeShift, Snapper does NOT link your <ROOT_FS> to a subdirectory under /, which is dangerous.
Comment