Restore Btrfs files at the push of a button with Snapper
Ubuntu and Debian with ext4 and Btrfs
On Debian sid/Siduction and Ubuntu, I tried to get Snapper and the Snapper GUI [8] running using ext4. Several attempts delivered mixed results that do not suggest a predictable experience; therefore, I would advise against the use of ext4 with Snapper right now. Because I had already installed all components and configurations for Snapper and the Snapper GUI, I decided to convert the existing ext4 filesystem to Btrfs.
The Debian instructions on how to perform such a conversion [9] were useful. After a subsequent reboot, Snapper and the Snapper GUI worked well together. Note, however, that it is faster to set up a new system with Btrfs than to convert from ext4. The process described here was more of an exercise to see whether the conversion could work at all.
While re-installing Ubuntu with Btrfs as the filesystem on a 30GB partition, I took advantage of putting the system under the control of LVM [10]. If you want to do this, select the Use LVM checkbox during installation, then right-click the partitions below Others at the bottom, which lets you choose Btrfs as the filesystem (Figure 7). The rest of the installation proceeds as usual. After restarting the installed system, you should first upgrade it, because each new kernel of late has introduced optimizations for Btrfs.
Next, install the snapper package; libpam-snapper, if needed, which launches Snapper when you log in to the system; and apt-btrfs-snapshot, which ensures that a snapshop is created after every upgrade with Apt. Then install snapper-gui
. As a precondition, you only need to install the git and python3-setuptools packages on a recent Ubuntu. Then, type
git clone --depth=1 https://github.com/ricardomv/snapper-gui.git cd snapper-gui/ sudo python3 setup.py install sudo snapper create-config / sudo snapper-gui
to download the code for and install the GUI, create a basic configuration for snapshots of the entire system, and launch the GUI, which is relatively self-explanatory with its sparse controls (Figure 8).
You can create configurations and open, remove, and view the differences between snapshots. You use the left Ctrl key to select the snapshots, and the changes are then displayed when you click on Changes (Figure 9). All told, the Snapper GUI offers roughly the same features as the YaST module in openSUSE. In the end, however, with a little practice, managing Snapper in a terminal window is not rocket science.
Snapper on Ubuntu, Debian, and probably other operating systems uses the same configuration file for snapshots as on openSUSE. Before you start production operation, you will want to check all the configurations you created in /etc/snapper/configs and modify them to match Listing 1 or to suit your own needs. All further management steps are as already described; the commands described for openSUSE also work on Debian and Ubuntu.
Although I chose to use LVM, it is not mandatory because Btrfs already has LVM functionality built in. Setting it up in this case can be viewed as more of a test as to whether the duplicate functions would interfere with each other, which could not be proved in the lab. An error with the apt-btrfs-snapshot package, which is supposed to ensure that a snapshot is automatically created after every upgrade with Apt, currently prevents it from working; therefore, before a system upgrade, you should use the command line or the GUI to create a snapshot.
Conclusions
Snapper optimizes the Btrfs snapshot feature, making it a valuable helper on systems subject to continuous change, such as developers and users of rolling release distributions. The software provides a valuable service by letting you roll back to a prior state before upgrading.
If you operate a stable system and do not install a lot of software daily, it is worthwhile calculating Snapper's overhead. Under certain circumstances it might be advisable to disable the snapshots launched every hour by cron and to only use automated snapshots when installing or upgrading.
The stability of Btrfs is an important factor. During the tests on three operating systems, more than 100 snapshots were created automatically and manually; they were compared, rolled back, and used to launch snapshot systems in GRUB. Under Btrfs, Snapper and the Snapper GUI on Ubuntu were stable; no errors endangered the data in any way. All the same, you should remember that Snapper is not a replacement for complete backups: In fact, it is more like the well-known Windows System Restore feature.
Infos
- Btrfs: http://en.wikipedia.org/wiki/Btrfs
- ZFS: https://en.wikipedia.org/wiki/ZFS
- Snapper in Arch: https://wiki.archlinux.org/index.php/Snapper#Create_a_new_configuration
- Snapper configuration: http://snapper.io/manpages/snapper-configs.html
- SUSE documentation for Snapper: https://www.suse.com/documentation/sles-12/book_sle_admin/data/sec_snapper_config.html
- Snapper man page: http://snapper.io/manpages/snapper.html
- Rolling back files: https://www.suse.com/documentation/sles-12/book_sle_admin/data/sec_snapper_snapshot-boot.html
- snapper-gui: https://github.com/ricardomv/snapper-gui
- Debian how-to: https://www.debian-administration.org/article/675/How_to_convert_a_Wheezy_or_newer_system_to_btrfs
- LVM: https://en.wikipedia.org/wiki/Logical_volume_management
« Previous 1 2
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
New Slimbook EVO with Raw AMD Ryzen Power
If you're looking for serious power in a 14" ultrabook that is powered by Linux, Slimbook has just the thing for you.
-
The Gnome Foundation Struggling to Stay Afloat
The foundation behind the Gnome desktop environment is having to go through some serious belt-tightening due to continued financial problems.
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.
-
OSI and LPI Form Strategic Alliance
With a goal of strengthening Linux and open source communities, this new alliance aims to nurture the growth of more highly skilled professionals.
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.