Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Snapper

News

Btrfs

Recommended Books

Recommended Links

ZFS

Snapshots

Ext2/Ext3 File System

ReiserFS
Snapper In-place conversion from ext3/4       Sysadmin Horror Stories Humor Etc

Snapper is a tool for managing btrfs snapshots introduced in SLES 11 SP2.  Btrfs file system is a new filesystem for Linux included in SLES 11 SP2 that delivers support for Copy on Write. It also includes powerful snapshot capabilities, integrated volume management and scalability through effective (online!) shrink. It also supports offline, in-place migration from ext2, ext3 and ext4. Other capabilities of btrfs include compression, checksums for improved data integrity and SSD optimization.

The SLES 11 SP 2 was the first major update to SUSE Enterprise Edition since the Novell business unit was re-formed as an operating division of Attachmate in 2011 and development was moved back to Germany.

Apart from the creation and deletion of snapshots it can compare snapshots and revert differences between snapshots. In simple terms, this allows users to view older versions of files and revert changes. Snapper is available as a command line interface tool and a YaST module. Both make use of the C++ library libsnapper which is also available to other programs.

Being able to do file system snapshots on Linux providing the ability to do rollbacks is a feature that was often requested in the past. Snapper, in conjunction with the Btrfs file system now fills that gap.

By default Snapper and Btrfs on SUSE Linux Enterprise Server are set up to serve as an undo tool for system changes made with YaST and zypper. Before and after running a YaST module or zypper, a snapshot is created. Snapper lets you compare the two snapshots and provides means to revert the differences between the two snapshots.

The tools also provide system backups by creating hourly snapshots of the system subvolumes.


Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

[Sep 07, 2012] Linux Don't Need No Stinkin' ZFS BTRFS Intro & Benchmarks Linux Magazine

Feature
BTRFS
Copy on Write yes
Snapshots yes
Snapshots of snapshots yes
Performance degradation at near 98-100% disk usage Most likely yes
Block level compression Currently a mount option
Disk encryption Planned but not currently in kernel. Encryptfs could be an option
Online resizing yes
Online defragmentation yes
Write checksums yes
Built-in RAID yes (0, 1, 10)
ACL yes
Direct IO Writes yes. Reads No – Planned
Quotas yes

[Apr 19, 2012] An introduction to system snapshot and rollback with Snapper and BtrFS on SLES 11 SP2 Novell User Communities

With the release of Service Pack 2 for SUSE Linux Enterprise Server 11, the support to a new (better) file system and a new (snappy) tool have been introduced providing the ability to do system snapshots rollbacks, a very powerful and interesting feature. These are BtrFS and Snapper respectively.

BtrFS

Btrfs is a new copy-on-write (COW) filesystem for Linux aimed at implementing advanced features while focusing on fault tolerance, repair and easy administration. Among the other things, BtrFS supports file system snapshots of subvolumes.

A subvolume in btrfs is not the same as an LVM logical volume as it is not a block device and thus cannot be treated as one. Rather, a btrfs subvolume can be thought of as a POSIX file namespace. This namespace can be accessed via the top-level subvolume of the filesystem, or it can be mounted in its own right. In other words, a subvolume can be seen just like a normal directory containing other files and other directories but with the possibility to be mounted like it was a filesystem on its own.

A snapshot is a copy of the state of a subvolume at a certain point of time, it is essentially a clone of a subvolume. In fact, snapshots and subvolumes are basically the same thing, they are separate "subvolume trees" within the "parent" file system, providing multiple root directories which can be mounted separately by label. By default there is at least one subvolume in every Btrfs filesystem, which is named "default"

There are many documents available on the internet about the topic. A good starting point to investigate it further is The Sysadmin's Guide to Btrfs

Snapper

Snapper is a tool for managing btrfs snapshots, it allows to create, delete and compare them as well as revert differences between them. In other words, it allows users to view older versions of files and revert changes.

Snapper is available as a command line interface tool and a YaST module.

By default Snapper and Btrfs on SUSE Linux Enterprise Server 11 Sp2 are set up to serve as an "undo tool" for system changes made with YaST and zypper. Before and after running a YaST module or zypper, a snapshot is created. Snapper lets you compare the two snapshots and provides means to revert the differences between the two snapshots. The tools also provide system backups by creating hourly snapshots of the system subvolumes.

Installation

In order to use BtrFS and Snapper as an "undo tool" for file system changes, the steps to take during the installation of the operating system are as simple as partitioning the hard disk with YaST and creating a partition for the boot mount point using an alternative file system, i.e. ext3 (currently it is not possible to boot from Btrfs partitions), and specifying the BtrFS for the root file system. Keep in mind that partitions containing snapshots need to be larger than "normal" ones. As a rule of thumb you should consider using twice the size than you normally would.

When selecting the file system Btrfs the button "subvolumes handling" is enabled to allow you to manage subvolumes. By default YaST automatically creates the following subvolumes when using BtrFS for the root file system:

Click to view.

These subvolumes are automatically created in order to exclude the specified path from snapshotting. For example, the directory /var/log is made a subvolume since reverting logs makes searching for problems difficult.

That's all is needed. Once completed with the partitioning it is possible to proceed with the installation as usual, Snapper will automatically be installed when the BtrFS file system is used. When planing for partitioning remember that snapshots will be available only for those partitions using BtrFS. So for example, if you create a own partition for /home consider to use BtrFS to take advantage of its functionalities.

Snapper in action

Now the system is ready to be used, Snapper is pre-configured for doing rollbacks of YaST or zypper changes. This means that every time you start a YaST module or a zypper transaction, two snapshots are created: 1) a "pre-snapshot" capturing the state of the filesystem before the start of the module and 2) a "post-snapshot" after the module has been finished.

By default, the last 100 YaST and zypper snapshots are being kept. It is possible to change this behavior as well as other settings of Snapper in the configuration file for the specific volume located in /etc/snapper/configs.

As an example, let's now try to modify a system setting using YaST and see how Snapper behaves.

  1. Let's launch YaST and simply create a new user with some basic information. (yast2 users from command line)

    Click to view.

  2. Once the user has been created close YaST and open it again, this time selecting the Snapper module, and see what it shows (yast2 snapper from command line).

    Click to view.

    This is the list of the available root filesystem snapshots. To fully understand this table it is important to understand that essentially there are three types of snapshots:

    • Single - used for storing the file system state in a certain time.
    • Pre - used for storing the file system state *before* the changes are made with YaST or zypper
    • Post - used for storing the file system state *after* the changes are made with YaST or zypper

    In our picture, notice the snapshot with ID "1" marked with the description "timeline". This is a snapshot of type "single" which help us to introduce another great feature about Snapper, the hourly snapshot. Apart from the YaST and zypper snapshots, Snapper by default creates hourly snapshots of the system partition (/). You can use these backup snapshots to restore files that have accidentally been deleted or modified beyond recovery. Even more interesting, using the Snapper's diff feature you can also find out which modifications have been made at a certain point of time.

    Back to our example, notice the two snapshots with ID "2" and "3" being on the same line and marked with the description "yast users". These are basically the Pre and Post snapshots which are coupled together to define the changes done by special operation, in our case the creation of the new user made via YaST.

  3. Let's select the pair of Pre and Post snapshots from the list referring to the changes we have applied via YaST when creating the new user. In our example the pair with ID "2-3". Click on "Show Changes" and following appears:

    Click to view.

    The tree on the left shows all the files that were modified between creating the Pre and the Post snapshots. On the right side, it is shown the description generated when the first snapshot was created and the time of creation of both snapshots.

    When a file is selected in the tree, you see the changes done to it: for a file which is changed it is possible to display a "diff" of it, for a file which has been created or removed it is simply indicated with a message "New file was created" or "New file was removed" respectively.

  4. Now let's select the file /etc/passwd from the tree and see the changes for it after having added the new user:

    Click to view.

  5. Let's then simulate a situation where the administrator of the server accidentally deletes the user just created and relative home directory from YaST (deleting the user from command line is not the same. Remember that by default snapshots are automatically taken when running YaST or zypper and on hourly basis)

    Click to view.

  6. As before, let's see what Snapper now shows:

    Click to view.

  7. A new pair of Pre and Post snapshots is listed referring to the latest changes we have applied via YaST when deleting the user "Snappy". Let's now select it and see the new changes for the file /etc/passwd

    Click to view.

  8. Now let's finally taste the goodness of Snapper and BtrFS simulating the "undo" of the user delete. Let's select the files to be restored, in this case all the files under /etc and /home, and click on "Restore Selected". A dialog listing all the files appears.

    Click to view.

  9. At this point click "Yes" to proceed with the restore of the user and.. that's it, if we now take a look at the list of existing users (yast2 users from command line) we can see the user back where he was before:

    Click to view.

The same operations (and even more) we have done so far with YaST are also available via command line, of course. The following are some examples:

Get a list of yast and zypper snapshots:

# snapper list -t pre-post

Get a list of changed files for a snapshot pair with ID 2 and 3:

# snapper status 2..3

To display the diff for a certain file:

# snapper diff 2..3 /etc/passwd

To restore all the changes:

# snapper -v undochange 2..3

To restore changes of one specific file:

# snapper -v undochange 2..3 /etc/passwd

...and many others..

Of course, this is intended to be only a simple example of the use of Snapper, however it is easy to think of many other scenarios where it can be used to get tremendous benefits not only in terms of fast system backup and restore but also as tool for tracking the activity on the system.

Many other examples and information about Snapper are available with the "SUSE Linux Enterprise Server 11 SP2 Administration Guide" available at the following link: http://www.suse.com/documentation/sles11/book_sle_admin/?page=/documentation/sles11/book_sle_admin/data/cha_snapper.html

A very interesting and funny video about Snapshot and Rollback from the Kernel Hacker Greg Kroah-Hartman and SUSE Product Manager Matthias Eckermann is available at the following link: http://www.youtube.com/watch?v=9H7e6BcI5Fo&feature=player_embedded


Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).

It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.

[Mar 16, 2012] SUSE Linux Enterprise Server 11 SP2 review by Koen Vervloesem

Mar 14, 2012 | http://www.linuxuser.co.uk/

Such a big jump in kernel version between service packs is not common for enterprise Linux distributions, which are usually quite conservative. For instance, Red Hat Enterprise Linux 5 is still using kernel version 2.6.18, even for its 8th update (RHEL 5.8), released a week after SLES 11 SP2, and in the same way RHEL 6.2 is still using kernel version 2.6.32. Of course these kernel versions contain a lot of backported features from newer kernel versions, but it's a lot of work to patch these features in and to keep maintaining them.

Instead of backporting and maintaining all those interesting features, SUSE's engineers have decided to use Linux 3.0 for SLES 11 SP2. This wasn't done rashly: they did an extensive code review of Linux 3.0 and verified that the kernel's Application Binary Interface (ABI) is completely compatible with SLE 11′s original 2.6.27 kernel. This guarantees that all software that ran on this kernel can expect exactly the same behaviour from the newer kernel release. So any software that has been certified for SLE 11 is still certified for SLE 11 SP2.

Ext3 is still the distro's default filesystem, but this is the first time Btrfs (which was introduced as a technology preview in SP1) is officially supported. However, SP2 still uses GRUB Legacy which can't boot from Btrfs, so when you choose Btrfs in the installer, SLE uses it as your root file system but creates a /boot partition with an Ext3 filesystem.

SUSE has also integrated the Snapper tool that it introduced in openSUSE 12.1 to manage Btrfs snapshots and rollbacks. The basic idea of Snapper is that it automatically creates a snapshot before and after running YaST or Zypper, compares the two snapshots and therefore provides the means to revert the differences between these two snapshots. You can list all the snapshots, see the differences between snapshots and roll them back using a user-friendly YaST module or with the commandline snapper tool. There's just one caveat: because the boot partition doesn't use Btrfs, you can't roll back kernel updates or changes to the boot configuration.

Thanks to Snapper, you can mess up system configuration changes or package installations or updates without having to restore from an old backup and risking to lose some files. Just revert to the snapshot before your problematic change and you're fine. But Snapper also helps with audits: it's very easy to discover which changes were made by which YaST or Zypper transaction. Snapper also creates cron jobs for periodic snapshots (which is configurable), so you'll be able to undo other manual changes too.

SP2 still offers Xen and KVM for virtualization, but it also introduces support for LXC (Linux containers), which is a form of operating system-level virtualization: when you create LXC containers, they are separate virtual servers, but all running on the same underlying Linux kernel of the host system. This lightweight virtualization method has a negligible overhead, as it's essentially a "chroot on steroids". On SP2, you can use LXC to isolate various system services from each other.


Recommended Links

Google matched content

Softpanorama Recommended

Top articles

Sites

PortalSnapper - openSUSE

Snapper tutorial

Snapper FAQ



Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: March 12, 2019