1.\" 2.\" CDDL HEADER START 3.\" 4.\" The contents of this file are subject to the terms of the 5.\" Common Development and Distribution License (the "License"). 6.\" You may not use this file except in compliance with the License. 7.\" 8.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9.\" or https://opensource.org/licenses/CDDL-1.0. 10.\" See the License for the specific language governing permissions 11.\" and limitations under the License. 12.\" 13.\" When distributing Covered Code, include this CDDL HEADER in each 14.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15.\" If applicable, add the following below this CDDL HEADER, with the 16.\" fields enclosed by brackets "[]" replaced with your own identifying 17.\" information: Portions Copyright [yyyy] [name of copyright owner] 18.\" 19.\" CDDL HEADER END 20.\" 21.\" Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved. 22.\" Copyright 2011 Joshua M. Clulow <josh@sysmgr.org> 23.\" Copyright (c) 2011, 2019 by Delphix. All rights reserved. 24.\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved. 25.\" Copyright (c) 2014, Joyent, Inc. All rights reserved. 26.\" Copyright (c) 2014 by Adam Stevko. All rights reserved. 27.\" Copyright (c) 2014 Integros [integros.com] 28.\" Copyright 2019 Richard Laager. All rights reserved. 29.\" Copyright 2018 Nexenta Systems, Inc. 30.\" Copyright 2019 Joyent, Inc. 31.\" 32.Dd March 16, 2022 33.Dt ZFS-SNAPSHOT 8 34.Os 35. 36.Sh NAME 37.Nm zfs-snapshot 38.Nd create snapshots of ZFS datasets 39.Sh SYNOPSIS 40.Nm zfs 41.Cm snapshot 42.Op Fl r 43.Oo Fl o Ar property Ns = Ns Ar value Oc Ns … 44.Ar dataset Ns @ Ns Ar snapname Ns … 45. 46.Sh DESCRIPTION 47Creates a snapshot of a dataset or multiple snapshots of different 48datasets. 49.Pp 50Snapshots are created atomically. 51That is, a snapshot is a consistent image of a dataset at a specific 52point in time; it includes all modifications to the dataset made by 53system calls that have successfully completed before that point in time. 54Recursive snapshots created through the 55.Fl r 56option are all created at the same time. 57.Pp 58.Nm zfs Cm snap 59can be used as an alias for 60.Nm zfs Cm snapshot . 61.Pp 62See the 63.Sx Snapshots 64section of 65.Xr zfsconcepts 7 66for details. 67.Bl -tag -width "-o" 68.It Fl o Ar property Ns = Ns Ar value 69Set the specified property; see 70.Nm zfs Cm create 71for details. 72.It Fl r 73Recursively create snapshots of all descendent datasets 74.El 75. 76.Sh EXAMPLES 77.\" These are, respectively, examples 2, 3, 10, 15 from zfs.8 78.\" Make sure to update them bidirectionally 79.Ss Example 1 : No Creating a ZFS Snapshot 80The following command creates a snapshot named 81.Ar yesterday . 82This snapshot is mounted on demand in the 83.Pa .zfs/snapshot 84directory at the root of the 85.Ar pool/home/bob 86file system. 87.Dl # Nm zfs Cm snapshot Ar pool/home/bob Ns @ Ns Ar yesterday 88. 89.Ss Example 2 : No Creating and Destroying Multiple Snapshots 90The following command creates snapshots named 91.Ar yesterday No of Ar pool/home 92and all of its descendent file systems. 93Each snapshot is mounted on demand in the 94.Pa .zfs/snapshot 95directory at the root of its file system. 96The second command destroys the newly created snapshots. 97.Dl # Nm zfs Cm snapshot Fl r Ar pool/home Ns @ Ns Ar yesterday 98.Dl # Nm zfs Cm destroy Fl r Ar pool/home Ns @ Ns Ar yesterday 99. 100.Ss Example 3 : No Promoting a ZFS Clone 101The following commands illustrate how to test out changes to a file system, and 102then replace the original file system with the changed one, using clones, clone 103promotion, and renaming: 104.Bd -literal -compact -offset Ds 105.No # Nm zfs Cm create Ar pool/project/production 106 populate /pool/project/production with data 107.No # Nm zfs Cm snapshot Ar pool/project/production Ns @ Ns Ar today 108.No # Nm zfs Cm clone Ar pool/project/production@today pool/project/beta 109 make changes to /pool/project/beta and test them 110.No # Nm zfs Cm promote Ar pool/project/beta 111.No # Nm zfs Cm rename Ar pool/project/production pool/project/legacy 112.No # Nm zfs Cm rename Ar pool/project/beta pool/project/production 113 once the legacy version is no longer needed, it can be destroyed 114.No # Nm zfs Cm destroy Ar pool/project/legacy 115.Ed 116. 117.Ss Example 4 : No Performing a Rolling Snapshot 118The following example shows how to maintain a history of snapshots with a 119consistent naming scheme. 120To keep a week's worth of snapshots, the user destroys the oldest snapshot, 121renames the remaining snapshots, and then creates a new snapshot, as follows: 122.Bd -literal -compact -offset Ds 123.No # Nm zfs Cm destroy Fl r Ar pool/users@7daysago 124.No # Nm zfs Cm rename Fl r Ar pool/users@6daysago No @ Ns Ar 7daysago 125.No # Nm zfs Cm rename Fl r Ar pool/users@5daysago No @ Ns Ar 6daysago 126.No # Nm zfs Cm rename Fl r Ar pool/users@4daysago No @ Ns Ar 5daysago 127.No # Nm zfs Cm rename Fl r Ar pool/users@3daysago No @ Ns Ar 4daysago 128.No # Nm zfs Cm rename Fl r Ar pool/users@2daysago No @ Ns Ar 3daysago 129.No # Nm zfs Cm rename Fl r Ar pool/users@yesterday No @ Ns Ar 2daysago 130.No # Nm zfs Cm rename Fl r Ar pool/users@today No @ Ns Ar yesterday 131.No # Nm zfs Cm snapshot Fl r Ar pool/users Ns @ Ns Ar today 132.Ed 133. 134.Sh SEE ALSO 135.Xr zfs-bookmark 8 , 136.Xr zfs-clone 8 , 137.Xr zfs-destroy 8 , 138.Xr zfs-diff 8 , 139.Xr zfs-hold 8 , 140.Xr zfs-rename 8 , 141.Xr zfs-rollback 8 , 142.Xr zfs-send 8 143