Rolling Back a ZFS Snapshot

You can to discard all changes made to a file system since a specific snapshot was created by using the zfs rollback command. The file system reverts to its state at the time the snapshot was taken. By default, the command cannot roll back to a snapshot other than the most recent snapshot.

To roll back to an earlier snapshot, you must destroy all intermediate snapshots by specifying the -r option.

If clones of any intermediate snapshots exist, use the -R option to destroy the clones as well.

Note:

The file system that you want to roll back must be unmounted and remounted, if it is currently mounted. If the file system cannot be unmounted, the rollback fails. Use the -f option to force the file system to be unmounted, if necessary.

In the following example, the system1/home/kaydo file system is rolled back to the tuesday snapshot.

$ zfs rollback system1/home/kaydo@tuesday
cannot rollback to 'system1/home/kaydo@tuesday': more recent snapshots exist
use '-r' to force deletion of the following snapshots:
system1/home/kaydo@wednesday
system1/home/kaydo@thursday
$ zfs rollback -r system1/home/kaydo@tuesday

In the following example, the wednesday and thursday snapshots are destroyed because the file system is rolled back to the earlier tuesday snapshot.

$ zfs list -r -t snapshot -o name,creation system1/home/kaydo
NAME                     CREATION
system1/home/kaydo@tuesday  Fri Aug  3 15:18 2012