Chapter 14. 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.
14.1. Creating Initial Snapper Configuration
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.
Warning
If you are using thin provisioning, monitor free space in the thin-pool. A fully consumed thin pool can result in data loss. For more information, see Thinly-Provisioned Logical Volumes (Thin Volumes) in the Red Hat Enterprise Linux 7 Logical Volume Manager Administration Guide.
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.
Note
Btrfs is available as a Technology Preview feature in Red Hat Enterprise Linux 7 but has been deprecated since the Red Hat Enterprise Linux 7.4 release. It will be removed in a future major release of Red Hat Enterprise Linux.
For more information, see Deprecated Functionality in the Red Hat Enterprise Linux 7.4 Release Notes.
Procedure 14.1. Creating a Snapper Configuration File
- Create or choose either:
- A thinly-provisioned logical volume with a Red Hat supported file system on top of it, or
- A Btrfs subvolume.
- Mount the file system.
- Create the configuration file that defines this volume.For LVM2:
#
snapper -c config_name create-config -f "lvm(fs_type)" /mount-point
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
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.
Alternatively, to create a configuration file calledbtrfs_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.