Snapshot names consist of the name of the filesystem, followed by an
@ and the name of the snapshot. For example, the snapshot
snapname of the filesystem
filesystem would be
We can list snapshots using the
zfs list command and specifying the type as snapshot:
zfs list -t snapshot
Snapshots are created using the
zfs snapshot command, or
zfs snap for short. We pass it the name of the snapshot we want to create.
For example, if we wanted to create a snapshot of
snap1, we run:
zfs snapshot rpool/example@snap1
Now, if we list all our snapshots, we should see our newly created snapshot in the list:
$ zfs list -t snapshot
NAME USED AVAIL REFER MOUNTPOINT
rpool/example@snap1 - - - -
Snapshots are deleted using the
zfs destroy command.
You may not delete a snapshot that has been cloned.
You must delete all clones of a snapshot before deleting it. We’ll go over cloning in the next sections.
You may not delete a dataset that has had snapshots made from it.
You must delete all snapshots originating from a dataset before deleting it.
For example, to delete our
rpool/example@snap1 snapshot from earlier, we specify it’s name in the
zfs destroy command:
zfs destroy rpool/example@snap1
If we list our snapshots again (
zfs list -t snapshot), the deleted one will no longer appear.
Snapshots can be renamed using the
zfs rename command. We pass in the current name, along with the new name.
For example, to rename our snapshot from earlier from
snap2, we run
zfs rename rpool/example@snap1 rpool/example@snap2. Note that the filesystem must be the same. This means that we couldn’t run
zfs rename rpool/example@snap1 rpool/something@snap2.
Since the filesystem must remain the same, for the example above, we could simply run
zfs rename rpool/example@snap1 snap2 to rename the pool to
Rolling back a snapshot
zfs rollback command, we can rollback the active filesystem to a snapshot. This will delete all changes made since the snapshot was created, reverting the active filesystem to that point in time.
If we wanted to rollback to our snapshot
rpool/example@snap1 from the examples above, we run
zfs rollback rpool/example@snap1.
Any snapshots made after the snapshot that you want to roll back to must be deleted.
You can do this automatically by adding the
-r flag to the
zfs rollback command.