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-RENAME 8
34eda14cbcSMatt Macy.Os
3516038816SMartin Matuska.
36eda14cbcSMatt Macy.Sh NAME
377877fdebSMatt Macy.Nm zfs-rename
3816038816SMartin Matuska.Nd rename ZFS dataset
39eda14cbcSMatt Macy.Sh SYNOPSIS
407877fdebSMatt Macy.Nm zfs
41eda14cbcSMatt Macy.Cm rename
42eda14cbcSMatt Macy.Op Fl f
43eda14cbcSMatt Macy.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
44eda14cbcSMatt Macy.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
457877fdebSMatt Macy.Nm zfs
46eda14cbcSMatt Macy.Cm rename
47eac7052fSMatt Macy.Fl p
48eac7052fSMatt Macy.Op Fl f
49eda14cbcSMatt Macy.Ar filesystem Ns | Ns Ar volume
50eda14cbcSMatt Macy.Ar filesystem Ns | Ns Ar volume
517877fdebSMatt Macy.Nm zfs
52eac7052fSMatt Macy.Cm rename
53eac7052fSMatt Macy.Fl u
54eac7052fSMatt Macy.Op Fl f
552c48331dSMatt Macy.Ar filesystem Ar filesystem
567877fdebSMatt Macy.Nm zfs
572c48331dSMatt Macy.Cm rename
582c48331dSMatt Macy.Fl r
592c48331dSMatt Macy.Ar snapshot Ar snapshot
6016038816SMartin Matuska.
61eda14cbcSMatt Macy.Sh DESCRIPTION
62eda14cbcSMatt Macy.Bl -tag -width ""
63eda14cbcSMatt Macy.It Xo
647877fdebSMatt Macy.Nm zfs
65eda14cbcSMatt Macy.Cm rename
66eda14cbcSMatt Macy.Op Fl f
67eda14cbcSMatt Macy.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
68eda14cbcSMatt Macy.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
69eda14cbcSMatt Macy.Xc
70eda14cbcSMatt Macy.It Xo
717877fdebSMatt Macy.Nm zfs
72eda14cbcSMatt Macy.Cm rename
73eac7052fSMatt Macy.Fl p
74eac7052fSMatt Macy.Op Fl f
75eda14cbcSMatt Macy.Ar filesystem Ns | Ns Ar volume
76eda14cbcSMatt Macy.Ar filesystem Ns | Ns Ar volume
77eda14cbcSMatt Macy.Xc
78eac7052fSMatt Macy.It Xo
797877fdebSMatt Macy.Nm zfs
80eac7052fSMatt Macy.Cm rename
81eac7052fSMatt Macy.Fl u
82eac7052fSMatt Macy.Op Fl f
83eac7052fSMatt Macy.Ar filesystem
84eac7052fSMatt Macy.Ar filesystem
85eac7052fSMatt Macy.Xc
86eda14cbcSMatt MacyRenames the given dataset.
87eda14cbcSMatt MacyThe new target can be located anywhere in the ZFS hierarchy, with the exception
88eda14cbcSMatt Macyof snapshots.
89eda14cbcSMatt MacySnapshots can only be renamed within the parent file system or volume.
90eda14cbcSMatt MacyWhen renaming a snapshot, the parent file system of the snapshot does not need
91eda14cbcSMatt Macyto be specified as part of the second argument.
92eda14cbcSMatt MacyRenamed file systems can inherit new mount points, in which case they are
93eda14cbcSMatt Macyunmounted and remounted at the new mount point.
94eda14cbcSMatt Macy.Bl -tag -width "-a"
95eda14cbcSMatt Macy.It Fl f
96eda14cbcSMatt MacyForce unmount any file systems that need to be unmounted in the process.
97eac7052fSMatt MacyThis flag has no effect if used together with the
98eac7052fSMatt Macy.Fl u
99eac7052fSMatt Macyflag.
100eda14cbcSMatt Macy.It Fl p
101eda14cbcSMatt MacyCreates all the nonexistent parent datasets.
102eda14cbcSMatt MacyDatasets created in this manner are automatically mounted according to the
103eda14cbcSMatt Macy.Sy mountpoint
104eda14cbcSMatt Macyproperty inherited from their parent.
105eac7052fSMatt Macy.It Fl u
106eac7052fSMatt MacyDo not remount file systems during rename.
107eac7052fSMatt MacyIf a file system's
108eac7052fSMatt Macy.Sy mountpoint
109eac7052fSMatt Macyproperty is set to
110eac7052fSMatt Macy.Sy legacy
111eac7052fSMatt Macyor
112eac7052fSMatt Macy.Sy none ,
113eac7052fSMatt Macythe file system is not unmounted even if this option is not given.
114eda14cbcSMatt Macy.El
115eda14cbcSMatt Macy.It Xo
1167877fdebSMatt Macy.Nm zfs
117eda14cbcSMatt Macy.Cm rename
118eda14cbcSMatt Macy.Fl r
119eda14cbcSMatt Macy.Ar snapshot Ar snapshot
120eda14cbcSMatt Macy.Xc
121eda14cbcSMatt MacyRecursively rename the snapshots of all descendent datasets.
122eda14cbcSMatt MacySnapshots are the only dataset that can be renamed recursively.
123eda14cbcSMatt Macy.El
124da5137abSMartin Matuska.
125da5137abSMartin Matuska.Sh EXAMPLES
126da5137abSMartin Matuska.\" These are, respectively, examples 10, 15 from zfs.8
127da5137abSMartin Matuska.\" Make sure to update them bidirectionally
128da5137abSMartin Matuska.Ss Example 1 : No Promoting a ZFS Clone
129da5137abSMartin MatuskaThe following commands illustrate how to test out changes to a file system, and
130da5137abSMartin Matuskathen replace the original file system with the changed one, using clones, clone
131da5137abSMartin Matuskapromotion, and renaming:
132da5137abSMartin Matuska.Bd -literal -compact -offset Ds
133da5137abSMartin Matuska.No # Nm zfs Cm create Ar pool/project/production
134da5137abSMartin Matuska  populate /pool/project/production with data
135da5137abSMartin Matuska.No # Nm zfs Cm snapshot Ar pool/project/production Ns @ Ns Ar today
136da5137abSMartin Matuska.No # Nm zfs Cm clone Ar pool/project/production@today pool/project/beta
137da5137abSMartin Matuska  make changes to /pool/project/beta and test them
138da5137abSMartin Matuska.No # Nm zfs Cm promote Ar pool/project/beta
139da5137abSMartin Matuska.No # Nm zfs Cm rename Ar pool/project/production pool/project/legacy
140da5137abSMartin Matuska.No # Nm zfs Cm rename Ar pool/project/beta pool/project/production
141da5137abSMartin Matuska  once the legacy version is no longer needed, it can be destroyed
142da5137abSMartin Matuska.No # Nm zfs Cm destroy Ar pool/project/legacy
143da5137abSMartin Matuska.Ed
144da5137abSMartin Matuska.
145da5137abSMartin Matuska.Ss Example 2 : No Performing a Rolling Snapshot
146da5137abSMartin MatuskaThe following example shows how to maintain a history of snapshots with a
147da5137abSMartin Matuskaconsistent naming scheme.
148da5137abSMartin MatuskaTo keep a week's worth of snapshots, the user destroys the oldest snapshot,
149da5137abSMartin Matuskarenames the remaining snapshots, and then creates a new snapshot, as follows:
150da5137abSMartin Matuska.Bd -literal -compact -offset Ds
151da5137abSMartin Matuska.No # Nm zfs Cm destroy Fl r Ar pool/users@7daysago
152da5137abSMartin Matuska.No # Nm zfs Cm rename Fl r Ar pool/users@6daysago No @ Ns Ar 7daysago
153da5137abSMartin Matuska.No # Nm zfs Cm rename Fl r Ar pool/users@5daysago No @ Ns Ar 6daysago
154da5137abSMartin Matuska.No # Nm zfs Cm rename Fl r Ar pool/users@4daysago No @ Ns Ar 5daysago
155da5137abSMartin Matuska.No # Nm zfs Cm rename Fl r Ar pool/users@3daysago No @ Ns Ar 4daysago
156da5137abSMartin Matuska.No # Nm zfs Cm rename Fl r Ar pool/users@2daysago No @ Ns Ar 3daysago
157da5137abSMartin Matuska.No # Nm zfs Cm rename Fl r Ar pool/users@yesterday No @ Ns Ar 2daysago
158da5137abSMartin Matuska.No # Nm zfs Cm rename Fl r Ar pool/users@today No @ Ns Ar yesterday
159da5137abSMartin Matuska.No # Nm zfs Cm snapshot Fl r Ar pool/users Ns @ Ns Ar today
160da5137abSMartin Matuska.Ed
161