19.3.6 Using snapper with Thinly-Provisioned Logical Volumes

You can use the snapper utility to create and manage thin snapshots of thinly-provisioned logical volumes.

To set up the snapper configuration for an existing mounted volume:

# snapper -c config_name create-config -f "lvm(fs_type)" fs_name

Here config_name is the name of the configuration, fs_type is the file system type (ext4 or xfs), and fs_name is the path of the file system. The command adds an entry for config_name to /etc/sysconfig/snapper, creates the configuration file /etc/snapper/configs/config_name, and sets up a .snapshots subdirectory for the snapshots.

By default, snapper sets up a cron.hourly job to create snapshots in the .snapshot subdirectory of the volume and a cron.daily job to clean up old snapshots. You can edit the configuration file to disable or change this behavior. For more information, see the snapper-configs(5) manual page.

There are three types of snapshot that you can create using snapper:

post

You use a post snapshot to record the state of a volume after a modification. A post snapshot should always be paired with a pre snapshot that you take immediately before you make the modification.

pre

You use a pre snapshot to record the state of a volume before a modification. A pre snapshot should always be paired with a post snapshot that you take immediately after you have completed the modification.

single

You can use a single snapshot to record the state of a volume but it does not have any association with other snapshots of the volume.

For example, the following commands create pre and post snapshots of a volume:

# snapper -c config_name create -t pre -p
N
... Modify the volume's contents ...
# snapper -c config_name create -t post --pre-num N -p
N'

The -p option causes snapper to display the number of the snapshot so that you can reference it when you create the post snapshot or when you compare the contents of the pre and post snapshots.

To display the files and directories that have been added, removed, or modified between the pre and post snapshots, use the status subcommand:

# snapper -c config_name status N..N'

To display the differences between the contents of the files in the pre and post snapshots, use the diff subcommand:

# snapper -c config_name diff N..N'

To list the snapshots that exist for a volume:

# snapper -c config_name list

To delete a snapshot, specify its number to the delete subcommand:

# snapper -c config_name delete N''

To undo the changes in the volume from post snapshot N' to pre snapshot N:

# snapper -c config_name undochange N..N'

For more information, see the snapper(8) manual page.