xref: /freebsd-src/sys/contrib/openzfs/man/man8/zfs-snapshot.8 (revision da5137abdf463bb5fee85061958a14dd12bc043e)
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
9eda14cbcSMatt Macy.\" or http://www.opensolaris.org/os/licensing.
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.\"
32*da5137abSMartin 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
47eda14cbcSMatt MacyAll previous modifications by successful system calls to the file system are
48eda14cbcSMatt Macypart of the snapshots.
49eda14cbcSMatt MacySnapshots are taken atomically, so that all snapshots correspond to the same
50eda14cbcSMatt Macymoment in time.
51eda14cbcSMatt Macy.Nm zfs Cm snap
52eda14cbcSMatt Macycan be used as an alias for
53eda14cbcSMatt Macy.Nm zfs Cm snapshot .
54eda14cbcSMatt MacySee the
5516038816SMartin Matuska.Sx Snapshots
56eda14cbcSMatt Macysection of
573ff01b23SMartin Matuska.Xr zfsconcepts 7
58eda14cbcSMatt Macyfor details.
59eda14cbcSMatt Macy.Bl -tag -width "-o"
60eda14cbcSMatt Macy.It Fl o Ar property Ns = Ns Ar value
6116038816SMartin MatuskaSet the specified property; see
62eda14cbcSMatt Macy.Nm zfs Cm create
63eda14cbcSMatt Macyfor details.
64eda14cbcSMatt Macy.It Fl r
65eda14cbcSMatt MacyRecursively create snapshots of all descendent datasets
66eda14cbcSMatt Macy.El
6716038816SMartin Matuska.
68*da5137abSMartin Matuska.Sh EXAMPLES
69*da5137abSMartin Matuska.\" These are, respectively, examples 2, 3, 10, 15 from zfs.8
70*da5137abSMartin Matuska.\" Make sure to update them bidirectionally
71*da5137abSMartin Matuska.Ss Example 1 : No Creating a ZFS Snapshot
72*da5137abSMartin MatuskaThe following command creates a snapshot named
73*da5137abSMartin Matuska.Ar yesterday .
74*da5137abSMartin MatuskaThis snapshot is mounted on demand in the
75*da5137abSMartin Matuska.Pa .zfs/snapshot
76*da5137abSMartin Matuskadirectory at the root of the
77*da5137abSMartin Matuska.Ar pool/home/bob
78*da5137abSMartin Matuskafile system.
79*da5137abSMartin Matuska.Dl # Nm zfs Cm snapshot Ar pool/home/bob Ns @ Ns Ar yesterday
80*da5137abSMartin Matuska.
81*da5137abSMartin Matuska.Ss Example 2 : No Creating and Destroying Multiple Snapshots
82*da5137abSMartin MatuskaThe following command creates snapshots named
83*da5137abSMartin Matuska.Ar yesterday No of Ar pool/home
84*da5137abSMartin Matuskaand all of its descendent file systems.
85*da5137abSMartin MatuskaEach snapshot is mounted on demand in the
86*da5137abSMartin Matuska.Pa .zfs/snapshot
87*da5137abSMartin Matuskadirectory at the root of its file system.
88*da5137abSMartin MatuskaThe second command destroys the newly created snapshots.
89*da5137abSMartin Matuska.Dl # Nm zfs Cm snapshot Fl r Ar pool/home Ns @ Ns Ar yesterday
90*da5137abSMartin Matuska.Dl # Nm zfs Cm destroy Fl r Ar pool/home Ns @ Ns Ar yesterday
91*da5137abSMartin Matuska.
92*da5137abSMartin Matuska.Ss Example 3 : No Promoting a ZFS Clone
93*da5137abSMartin MatuskaThe following commands illustrate how to test out changes to a file system, and
94*da5137abSMartin Matuskathen replace the original file system with the changed one, using clones, clone
95*da5137abSMartin Matuskapromotion, and renaming:
96*da5137abSMartin Matuska.Bd -literal -compact -offset Ds
97*da5137abSMartin Matuska.No # Nm zfs Cm create Ar pool/project/production
98*da5137abSMartin Matuska  populate /pool/project/production with data
99*da5137abSMartin Matuska.No # Nm zfs Cm snapshot Ar pool/project/production Ns @ Ns Ar today
100*da5137abSMartin Matuska.No # Nm zfs Cm clone Ar pool/project/production@today pool/project/beta
101*da5137abSMartin Matuska  make changes to /pool/project/beta and test them
102*da5137abSMartin Matuska.No # Nm zfs Cm promote Ar pool/project/beta
103*da5137abSMartin Matuska.No # Nm zfs Cm rename Ar pool/project/production pool/project/legacy
104*da5137abSMartin Matuska.No # Nm zfs Cm rename Ar pool/project/beta pool/project/production
105*da5137abSMartin Matuska  once the legacy version is no longer needed, it can be destroyed
106*da5137abSMartin Matuska.No # Nm zfs Cm destroy Ar pool/project/legacy
107*da5137abSMartin Matuska.Ed
108*da5137abSMartin Matuska.
109*da5137abSMartin Matuska.Ss Example 4 : No Performing a Rolling Snapshot
110*da5137abSMartin MatuskaThe following example shows how to maintain a history of snapshots with a
111*da5137abSMartin Matuskaconsistent naming scheme.
112*da5137abSMartin MatuskaTo keep a week's worth of snapshots, the user destroys the oldest snapshot,
113*da5137abSMartin Matuskarenames the remaining snapshots, and then creates a new snapshot, as follows:
114*da5137abSMartin Matuska.Bd -literal -compact -offset Ds
115*da5137abSMartin Matuska.No # Nm zfs Cm destroy Fl r Ar pool/users@7daysago
116*da5137abSMartin Matuska.No # Nm zfs Cm rename Fl r Ar pool/users@6daysago No @ Ns Ar 7daysago
117*da5137abSMartin Matuska.No # Nm zfs Cm rename Fl r Ar pool/users@5daysago No @ Ns Ar 6daysago
118*da5137abSMartin Matuska.No # Nm zfs Cm rename Fl r Ar pool/users@4daysago No @ Ns Ar 5daysago
119*da5137abSMartin Matuska.No # Nm zfs Cm rename Fl r Ar pool/users@3daysago No @ Ns Ar 4daysago
120*da5137abSMartin Matuska.No # Nm zfs Cm rename Fl r Ar pool/users@2daysago No @ Ns Ar 3daysago
121*da5137abSMartin Matuska.No # Nm zfs Cm rename Fl r Ar pool/users@yesterday No @ Ns Ar 2daysago
122*da5137abSMartin Matuska.No # Nm zfs Cm rename Fl r Ar pool/users@today No @ Ns Ar yesterday
123*da5137abSMartin Matuska.No # Nm zfs Cm snapshot Fl r Ar pool/users Ns @ Ns Ar today
124*da5137abSMartin Matuska.Ed
125*da5137abSMartin Matuska.
126eda14cbcSMatt Macy.Sh SEE ALSO
127eda14cbcSMatt Macy.Xr zfs-bookmark 8 ,
128eda14cbcSMatt Macy.Xr zfs-clone 8 ,
129eda14cbcSMatt Macy.Xr zfs-destroy 8 ,
130eda14cbcSMatt Macy.Xr zfs-diff 8 ,
131eda14cbcSMatt Macy.Xr zfs-hold 8 ,
132eda14cbcSMatt Macy.Xr zfs-rename 8 ,
133eda14cbcSMatt Macy.Xr zfs-rollback 8 ,
134eda14cbcSMatt Macy.Xr zfs-send 8
135