Solaris ZFS Administration Guide

Rolling Back a ZFS Snapshot

The zfs rollback command can be used to discard all changes made since a specific snapshot. 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, all intermediate snapshots must be destroyed. You can destroy earlier snapshots by specifying the -r option.

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


Note –

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


In the following example, the tank/home/ahrens file system is rolled back to the tuesday snapshot:


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

In the above example, the wednesday and thursday snapshots are removed because you rolled back to the previous tuesday snapshot.


# zfs list -r -t snapshot -o name,creation tank/home/ahrens
NAME                      CREATION
tank/home/ahrens@tuesday  Wed Aug 27 16:35 2009