Holding ZFS Snapshots
Older snapshots are sometimes inadvertently destroyed due to different automatic snapshot or data retention policies. If a removed snapshot is part of an ongoing ZFS send and receive operation, then the operation might fail. To avoid this scenario, consider placing a hold on a snapshot.
                  Holding a snapshot prevents it from being destroyed. In addition, this feature allows a snapshot with clones to be deleted pending the removal of the last clone by using the zfs destroy -d
                    command. Each snapshot has an associated user-reference count, which is initialized to zero. This count increases by 1 whenever a hold is put on a snapshot and decreases by 1 whenever a hold is released.
               
In the previous Oracle Solaris release, you could destroy a snapshot only by using the zfs destroy command if it had no clones. In this Oracle Solaris release, the snapshot must also have a zero user-reference count.
               
You can hold a snapshot or set of snapshots. For example, the following syntax
                    puts a hold tag, keep, on
system1/home/kaydo/snap@1:
               
$ zfs hold keep system1/home/kaydo@snap1To recursively hold the snapshots of all descendant file systems, use the -r option. For example:
               
$ zfs snapshot -r system1/home@now $ zfs hold -r keep system1/home@now
This syntax adds a single reference, keep, to the given snapshot or set of snapshots. Each snapshot has its own tag namespace and hold tags must be unique within that space. If a hold exists on a snapshot, attempts to destroy that held snapshot by using the zfs destroy command will fail. For example:
               
$ zfs destroy system1/home/kaydo@snap1
cannot destroy 'system1/home/kaydo@snap1': dataset is busyTo destroy a held snapshot, use the -d option. For example:
               
$ zfs destroy -d system1/home/kaydo@snap1To display a list of held snapshots, use the zfs holds command. For example:
               
$ zfs holds system1/home@now
NAME              TAG   TIMESTAMP
system1/home@now  keep  Fri Aug  3 15:15:53 2012  $ zfs holds -r system1/home@now
NAME                    TAG   TIMESTAMP
system1/home/kaydo@now  keep  Fri Aug  3 15:15:53 2012
system1/home/glori@now  keep  Fri Aug  3 15:15:53 2012
system1/home/hsolo@now  keep  Fri Aug  3 15:15:53 2012
system1/home/cpark@now  keep  Fri Aug  3 15:15:53 2012
system1/home@now        keep  Fri Aug  3 15:15:53 2012  To release a hold on a snapshot or set of snapshots, use the zfs release command. For example:
               
$ zfs release -r keep system1/home@nowIf the snapshot is released, the snapshot can be destroyed by using the zfs destroy command. For example:
               
$ zfs destroy -r system1/home@nowTwo properties identify snapshot hold information.
- 
                     
                     The destroyerproperty is set toonif the snapshot has been marked for deferred destruction by using thezfs destroy -dcommand. Otherwise, the property is set tooff.
- 
                     
                     The userrefsproperty is set to the number of holds on this snapshot.