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