xref: /freebsd/sys/contrib/openzfs/man/man8/zfs-rename.8 (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1.\" SPDX-License-Identifier: CDDL-1.0
2.\"
3.\" CDDL HEADER START
4.\"
5.\" The contents of this file are subject to the terms of the
6.\" Common Development and Distribution License (the "License").
7.\" You may not use this file except in compliance with the License.
8.\"
9.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10.\" or https://opensource.org/licenses/CDDL-1.0.
11.\" See the License for the specific language governing permissions
12.\" and limitations under the License.
13.\"
14.\" When distributing Covered Code, include this CDDL HEADER in each
15.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16.\" If applicable, add the following below this CDDL HEADER, with the
17.\" fields enclosed by brackets "[]" replaced with your own identifying
18.\" information: Portions Copyright [yyyy] [name of copyright owner]
19.\"
20.\" CDDL HEADER END
21.\"
22.\" Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
23.\" Copyright 2011 Joshua M. Clulow <josh@sysmgr.org>
24.\" Copyright (c) 2011, 2019 by Delphix. All rights reserved.
25.\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
26.\" Copyright (c) 2014, Joyent, Inc. All rights reserved.
27.\" Copyright (c) 2014 by Adam Stevko. All rights reserved.
28.\" Copyright (c) 2014 Integros [integros.com]
29.\" Copyright 2019 Richard Laager. All rights reserved.
30.\" Copyright 2018 Nexenta Systems, Inc.
31.\" Copyright 2019 Joyent, Inc.
32.\"
33.Dd March 16, 2022
34.Dt ZFS-RENAME 8
35.Os
36.
37.Sh NAME
38.Nm zfs-rename
39.Nd rename ZFS dataset
40.Sh SYNOPSIS
41.Nm zfs
42.Cm rename
43.Op Fl f
44.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
45.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
46.Nm zfs
47.Cm rename
48.Fl p
49.Op Fl f
50.Ar filesystem Ns | Ns Ar volume
51.Ar filesystem Ns | Ns Ar volume
52.Nm zfs
53.Cm rename
54.Fl u
55.Op Fl f
56.Ar filesystem Ar filesystem
57.Nm zfs
58.Cm rename
59.Fl r
60.Ar snapshot Ar snapshot
61.
62.Sh DESCRIPTION
63.Bl -tag -width ""
64.It Xo
65.Nm zfs
66.Cm rename
67.Op Fl f
68.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
69.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
70.Xc
71.It Xo
72.Nm zfs
73.Cm rename
74.Fl p
75.Op Fl f
76.Ar filesystem Ns | Ns Ar volume
77.Ar filesystem Ns | Ns Ar volume
78.Xc
79.It Xo
80.Nm zfs
81.Cm rename
82.Fl u
83.Op Fl f
84.Ar filesystem
85.Ar filesystem
86.Xc
87Renames the given dataset.
88The new target can be located anywhere in the ZFS hierarchy, with the exception
89of snapshots.
90Snapshots can only be renamed within the parent file system or volume.
91When renaming a snapshot, the parent file system of the snapshot does not need
92to be specified as part of the second argument.
93Renamed file systems can inherit new mount points, in which case they are
94unmounted and remounted at the new mount point.
95.Bl -tag -width "-a"
96.It Fl f
97Force unmount any file systems that need to be unmounted in the process.
98This flag has no effect if used together with the
99.Fl u
100flag.
101.It Fl p
102Creates all the nonexistent parent datasets.
103Datasets created in this manner are automatically mounted according to the
104.Sy mountpoint
105property inherited from their parent.
106.It Fl u
107Do not remount file systems during rename.
108If a file system's
109.Sy mountpoint
110property is set to
111.Sy legacy
112or
113.Sy none ,
114the file system is not unmounted even if this option is not given.
115.El
116.It Xo
117.Nm zfs
118.Cm rename
119.Fl r
120.Ar snapshot Ar snapshot
121.Xc
122Recursively rename the snapshots of all descendent datasets.
123Snapshots are the only dataset that can be renamed recursively.
124.El
125.
126.Sh EXAMPLES
127.\" These are, respectively, examples 10, 15 from zfs.8
128.\" Make sure to update them bidirectionally
129.Ss Example 1 : No Promoting a ZFS Clone
130The following commands illustrate how to test out changes to a file system, and
131then replace the original file system with the changed one, using clones, clone
132promotion, and renaming:
133.Bd -literal -compact -offset Ds
134.No # Nm zfs Cm create Ar pool/project/production
135  populate /pool/project/production with data
136.No # Nm zfs Cm snapshot Ar pool/project/production Ns @ Ns Ar today
137.No # Nm zfs Cm clone Ar pool/project/production@today pool/project/beta
138  make changes to /pool/project/beta and test them
139.No # Nm zfs Cm promote Ar pool/project/beta
140.No # Nm zfs Cm rename Ar pool/project/production pool/project/legacy
141.No # Nm zfs Cm rename Ar pool/project/beta pool/project/production
142  once the legacy version is no longer needed, it can be destroyed
143.No # Nm zfs Cm destroy Ar pool/project/legacy
144.Ed
145.
146.Ss Example 2 : No Performing a Rolling Snapshot
147The following example shows how to maintain a history of snapshots with a
148consistent naming scheme.
149To keep a week's worth of snapshots, the user destroys the oldest snapshot,
150renames the remaining snapshots, and then creates a new snapshot, as follows:
151.Bd -literal -compact -offset Ds
152.No # Nm zfs Cm destroy Fl r Ar pool/users@7daysago
153.No # Nm zfs Cm rename Fl r Ar pool/users@6daysago No @ Ns Ar 7daysago
154.No # Nm zfs Cm rename Fl r Ar pool/users@5daysago No @ Ns Ar 6daysago
155.No # Nm zfs Cm rename Fl r Ar pool/users@4daysago No @ Ns Ar 5daysago
156.No # Nm zfs Cm rename Fl r Ar pool/users@3daysago No @ Ns Ar 4daysago
157.No # Nm zfs Cm rename Fl r Ar pool/users@2daysago No @ Ns Ar 3daysago
158.No # Nm zfs Cm rename Fl r Ar pool/users@yesterday No @ Ns Ar 2daysago
159.No # Nm zfs Cm rename Fl r Ar pool/users@today No @ Ns Ar yesterday
160.No # Nm zfs Cm snapshot Fl r Ar pool/users Ns @ Ns Ar today
161.Ed
162