Language and Page Formatting Options
14.4. Reversing Changes in Between Snapshots
To reverse changes made between two existing Snapper snapshots, use the
undochangecommand in the following format, where
1is the first snapshot and
2is the second snapshot:
snapper -c config_name undochange 1..2
undochangecommand does not revert the Snapper volume back to its original state and does not provide data consistency. Any file modification that occurs outside of the specified range, for example after snapshot 2, will remain unchanged after reverting back, for example to the state of snapshot 1. For example, if
undochangeis run to undo the creation of a user, any files owned by that user can still remain.
There is also no mechanism to ensure file consistency as a snapshot is made, so any inconsistencies that already exist can be transferred back to the snapshot when the
undochangecommand is used.
Do not use the Snapper
undochangecommand with the root file system, as doing so is likely to lead to a failure.
The following diagram demonstrates how the
Figure 14.1. Snapper Status over Time
The diagram shows the point in time in which
file_ais created, then
Snapshot_2is then created, after which
file_ais edited and
file_cis created. This is now the current state of the system. The current system has an edited version of
file_b, and a newly created
undochangecommand is called, Snapper generates a list of modified files between the first listed snapshot and the second. In the diagram, if you use the
snapper -c SnapperExample undochange 1..2command, Snapper creates a list of modified files (that is,
file_bis deleted) and applies them to the current system. Therefore:
Be aware that if
- the current system will not have
file_a, as it has yet to be created when
file_bwill exist, copied from
snapshot_1into the current system.
file_cwill exist, as its creation was outside the specified time.
file_cconflict, the system can become corrupted.
You can also use the
snapper -c SnapperExample undochange 2..1command. In this case, the current system replaces the edited version of
file_awith one copied from
snapshot_1, which undoes edits of that file made after
Using the mount and unmount Commands to Reverse Changes
undochangecommand is not always the best way to revert modifications. With the
diffcommand, you can make a qualified decision, and use the
unmountcommands instead of Snapper. The
unmountcommands are only useful if you want to mount snapshots and browse their content independently of Snapper workflow.
If needed, the
mountcommand activates respective LVM Snapper snapshot before mounting. Use the
unmountcommands if you are, for example, interested in mounting snapshots and extracting older version of several files manually. To revert files manually, copy them from a mounted snapshot to the current file system. The current file system, snapshot 0, is the live file system created in Procedure 14.1, “Creating a Snapper Configuration File”. Copy the files to the subtree of the original /mount-point.
unmountcommands for explicit client-side requests. The
/etc/snapper/configs/config_namefile contains the ALLOW_USERS= and ALLOW_GROUPS= variables where you can add users and groups. Then,
snapperdallows you to perform mount operations for the added users and groups.