Creating and Destroying ZFS Snapshots

You create snapshots by using the zfs snapshot or the zfs snap command, which takes as its only argument the name of the snapshot to create. The snapshot name uses one of the following conventions:

  • filesystem@snapname

  • volume@snapname

The snapshot name must satisfy the naming requirements in Naming ZFS Components.

The following example creates a snapshot of system1/home/kaydo that is named friday.

$ zfs snapshot system1/home/kaydo@friday

To create snapshots for all descendant file systems, use the rr option. For example:

$ zfs snapshot -r system1/home@snap1
$ zfs list -t snapshot -r system1/home
NAME                      USED  AVAIL   REFER  MOUNTPOINT
system1/home@snap1           0      -   2.11G  -
system1/home/kaydo@snap1     0      -    115M  -
system1/home/glori@snap1     0      -   2.00G  -
system1/home/hsolo@snap1     0      -   2.00G  -
system1/home/cpark@snap1     0      -   57.3M  -

Snapshots have no modifiable properties, nor can dataset properties be applied to a snapshot. For example:

$ zfs set compression=on system1/home/kaydo@friday
cannot set property for 'system1/home/kaydo@friday':
this property can not be modified for snapshots

To destroy snapshots, use the zfs destroy command. For example:

$ zfs destroy system1/home/kaydo@friday

You cannot destroy a dataset if snapshots of the dataset exist. For example:

$ zfs destroy system1/home/kaydo
cannot destroy 'system1/home/kaydo': filesystem has children
use '-r' to destroy the following datasets:
system1/home/kaydo@tuesday
system1/home/kaydo@wednesday
system1/home/kaydo@thursday

In addition, if clones have been created from a snapshot, then you must destroy them before you can destroy the snapshot.

For more information about the destroy subcommand, see How to Destroy a ZFS File System.