Chapter 13. Creating and Maintaining Snapshots with Snapper

A snapshot volume is a point in time copy of a target volume that provides a way to revert a file system back to an earlier state. Snapper is a command-line tool to create and maintain snapshots for Btrfs and thinly-provisioned LVM file systems.

13.1. Initial Snapper Setup

Snapper requires discrete configuration files for each volume it operates on. You must set up the configuration files manually. By default, only the root user is allowed to perform snapper commands.
Red Hat recommends using the ext4 file system with Snapper on Red Hat Enterprise Linux 7. Use the XFS file system on lvm-thin volumes only if you are monitoring the amount of free space in the pool to prevent out-of-space problems that can lead to a failure.
Note that the Btrfs tools and file system are provided as a Technology Preview, which make them unsuitable for production systems.
Although it is possible to allow a user or group other than root to use certain Snapper commands, Red Hat recommends that you do not add elevated permissions to otherwise unprivileged users or groups. Such a configuration bypasses SELinux and could pose a security risk. Red Hat recommends that you review these capabilities with your Security Team and consider using the sudo infrastructure instead.

Procedure 13.1. Creating a Snapper Configuration File

  1. Create or choose either:
    • A thinly-provisioned logical volume with a Red Hat supported file system on top of it, or
    • A Btrfs subvolume.
  2. Mount the file system.
  3. Create the configuration file that defines this volume.
    For LVM2:
    # snapper -c config_name create-config -f "lvm(fs_type)" /mount-point
    For Btrfs:
    # snapper -c config_name create-config -f btrfs /mount-point
    • The -c config_name option specifies the name of the configuration file.
    • The create-config tells snapper to create a configuration file.
    • The -f file_system tells snapper what file system to use; if this is omitted snapper will attempt to detect the file system.
    • The /mount-point is where the subvolume or thinly-provisioned LVM2 file system is mounted.
    For example, to create a configuration file called lvm_config on an LVM2 subvolume with an ext4 file system, mounted at /lvm_mount, use:
    # snapper -c lvm_config create-config -f "lvm(ext4)" /lvm_mount
    Alternatively, to create a configuration file called btrfs_config, on a Btrfs subvolume that is mounted at /btrfs_mount, use:
    # snapper -c btrfs_config create-config -f btrfs /btrfs_mount
The configuration files are stored in the /etc/snapper/configs/ directory.