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.

Figure 7: Selecting Btrfs in the installer.

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).

Figure 8: Creating the first snapshot.

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.

Figure 9: Differences between two snapshots.

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.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Snapper

    Snapper lets you restore a system to its previous state – with a little help from Btrfs snapshots.

  • Snapshot Tools

    Experts agree that you should keep a copy of your data, but restoring from incremental backups takes time and sometimes doesn't work as expected. Alternatively, you can capture your data in a snapshot. Read on for a review of some leading Linux snapshot tools.

  • Btrfs

    The Btrfs filesystem offers advanced features such as RAID, subvolumes, snapshots, checksums, and transparent compression, but do desktop users really need all that power?

  • On the DVD: openSUSE 12.1 & Fedora 16

    With this month’s DVD, you get to test the latest offerings from the openSUSE [1] and Fedora [2] projects

  • This Month's DVD

    Linux Mint 17.3 Cinnamon Edition and openSUSE Leap 42.1

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News