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-DESTROY 8 34eda14cbcSMatt Macy.Os 3516038816SMartin Matuska. 36eda14cbcSMatt Macy.Sh NAME 377877fdebSMatt Macy.Nm zfs-destroy 3816038816SMartin Matuska.Nd destroy ZFS dataset, snapshots, or bookmark 39eda14cbcSMatt Macy.Sh SYNOPSIS 407877fdebSMatt Macy.Nm zfs 41eda14cbcSMatt Macy.Cm destroy 42eda14cbcSMatt Macy.Op Fl Rfnprv 43eda14cbcSMatt Macy.Ar filesystem Ns | Ns Ar volume 447877fdebSMatt Macy.Nm zfs 45eda14cbcSMatt Macy.Cm destroy 46eda14cbcSMatt Macy.Op Fl Rdnprv 47eda14cbcSMatt Macy.Ar filesystem Ns | Ns Ar volume Ns @ Ns Ar snap Ns 4816038816SMartin Matuska.Oo % Ns Ar snap Ns Oo , Ns Ar snap Ns Oo % Ns Ar snap Oc Oc Oc Ns … 497877fdebSMatt Macy.Nm zfs 50eda14cbcSMatt Macy.Cm destroy 51eda14cbcSMatt Macy.Ar filesystem Ns | Ns Ar volume Ns # Ns Ar bookmark 5216038816SMartin Matuska. 53eda14cbcSMatt Macy.Sh DESCRIPTION 54eda14cbcSMatt Macy.Bl -tag -width "" 55eda14cbcSMatt Macy.It Xo 567877fdebSMatt Macy.Nm zfs 57eda14cbcSMatt Macy.Cm destroy 58eda14cbcSMatt Macy.Op Fl Rfnprv 59eda14cbcSMatt Macy.Ar filesystem Ns | Ns Ar volume 60eda14cbcSMatt Macy.Xc 61eda14cbcSMatt MacyDestroys the given dataset. 62eda14cbcSMatt MacyBy default, the command unshares any file systems that are currently shared, 63eda14cbcSMatt Macyunmounts any file systems that are currently mounted, and refuses to destroy a 64eda14cbcSMatt Macydataset that has active dependents 65eda14cbcSMatt Macy.Pq children or clones . 66eda14cbcSMatt Macy.Bl -tag -width "-R" 67eda14cbcSMatt Macy.It Fl R 68eda14cbcSMatt MacyRecursively destroy all dependents, including cloned file systems outside the 69eda14cbcSMatt Macytarget hierarchy. 70eda14cbcSMatt Macy.It Fl f 7116038816SMartin MatuskaForcibly unmount file systems. 72eda14cbcSMatt MacyThis option has no effect on non-file systems or unmounted file systems. 73eda14cbcSMatt Macy.It Fl n 74eda14cbcSMatt MacyDo a dry-run 75eda14cbcSMatt Macy.Pq Qq No-op 76eda14cbcSMatt Macydeletion. 77eda14cbcSMatt MacyNo data will be deleted. 78eda14cbcSMatt MacyThis is useful in conjunction with the 79eda14cbcSMatt Macy.Fl v 80eda14cbcSMatt Macyor 81eda14cbcSMatt Macy.Fl p 82eda14cbcSMatt Macyflags to determine what data would be deleted. 83eda14cbcSMatt Macy.It Fl p 84eda14cbcSMatt MacyPrint machine-parsable verbose information about the deleted data. 85eda14cbcSMatt Macy.It Fl r 86eda14cbcSMatt MacyRecursively destroy all children. 87eda14cbcSMatt Macy.It Fl v 88eda14cbcSMatt MacyPrint verbose information about the deleted data. 89eda14cbcSMatt Macy.El 90eda14cbcSMatt Macy.Pp 91eda14cbcSMatt MacyExtreme care should be taken when applying either the 92eda14cbcSMatt Macy.Fl r 93eda14cbcSMatt Macyor the 94eda14cbcSMatt Macy.Fl R 95eda14cbcSMatt Macyoptions, as they can destroy large portions of a pool and cause unexpected 96eda14cbcSMatt Macybehavior for mounted file systems in use. 97eda14cbcSMatt Macy.It Xo 987877fdebSMatt Macy.Nm zfs 99eda14cbcSMatt Macy.Cm destroy 100eda14cbcSMatt Macy.Op Fl Rdnprv 101eda14cbcSMatt Macy.Ar filesystem Ns | Ns Ar volume Ns @ Ns Ar snap Ns 10216038816SMartin Matuska.Oo % Ns Ar snap Ns Oo , Ns Ar snap Ns Oo % Ns Ar snap Oc Oc Oc Ns … 103eda14cbcSMatt Macy.Xc 104eda14cbcSMatt MacyThe given snapshots are destroyed immediately if and only if the 10516038816SMartin Matuska.Nm zfs Cm destroy 106eda14cbcSMatt Macycommand without the 107eda14cbcSMatt Macy.Fl d 108eda14cbcSMatt Macyoption would have destroyed it. 109eda14cbcSMatt MacySuch immediate destruction would occur, for example, if the snapshot had no 110eda14cbcSMatt Macyclones and the user-initiated reference count were zero. 111eda14cbcSMatt Macy.Pp 112eda14cbcSMatt MacyIf a snapshot does not qualify for immediate destruction, it is marked for 113eda14cbcSMatt Macydeferred deletion. 114eda14cbcSMatt MacyIn this state, it exists as a usable, visible snapshot until both of the 115eda14cbcSMatt Macypreconditions listed above are met, at which point it is destroyed. 116eda14cbcSMatt Macy.Pp 117eda14cbcSMatt MacyAn inclusive range of snapshots may be specified by separating the first and 118eda14cbcSMatt Macylast snapshots with a percent sign. 119eda14cbcSMatt MacyThe first and/or last snapshots may be left blank, in which case the 120eda14cbcSMatt Macyfilesystem's oldest or newest snapshot will be implied. 121eda14cbcSMatt Macy.Pp 122eda14cbcSMatt MacyMultiple snapshots 123eda14cbcSMatt Macy.Pq or ranges of snapshots 124eda14cbcSMatt Macyof the same filesystem or volume may be specified in a comma-separated list of 125eda14cbcSMatt Macysnapshots. 126eda14cbcSMatt MacyOnly the snapshot's short name 127eda14cbcSMatt Macy.Po the part after the 128eda14cbcSMatt Macy.Sy @ 129eda14cbcSMatt Macy.Pc 130eda14cbcSMatt Macyshould be specified when using a range or comma-separated list to identify 131eda14cbcSMatt Macymultiple snapshots. 132eda14cbcSMatt Macy.Bl -tag -width "-R" 133eda14cbcSMatt Macy.It Fl R 134eda14cbcSMatt MacyRecursively destroy all clones of these snapshots, including the clones, 135eda14cbcSMatt Macysnapshots, and children. 136eda14cbcSMatt MacyIf this flag is specified, the 137eda14cbcSMatt Macy.Fl d 138eda14cbcSMatt Macyflag will have no effect. 139eda14cbcSMatt Macy.It Fl d 14016038816SMartin MatuskaDestroy immediately. 14116038816SMartin MatuskaIf a snapshot cannot be destroyed now, mark it for deferred destruction. 142eda14cbcSMatt Macy.It Fl n 143eda14cbcSMatt MacyDo a dry-run 144eda14cbcSMatt Macy.Pq Qq No-op 145eda14cbcSMatt Macydeletion. 146eda14cbcSMatt MacyNo data will be deleted. 147eda14cbcSMatt MacyThis is useful in conjunction with the 148eda14cbcSMatt Macy.Fl p 149eda14cbcSMatt Macyor 150eda14cbcSMatt Macy.Fl v 151eda14cbcSMatt Macyflags to determine what data would be deleted. 152eda14cbcSMatt Macy.It Fl p 153eda14cbcSMatt MacyPrint machine-parsable verbose information about the deleted data. 154eda14cbcSMatt Macy.It Fl r 155eda14cbcSMatt MacyDestroy 156eda14cbcSMatt Macy.Pq or mark for deferred deletion 157eda14cbcSMatt Macyall snapshots with this name in descendent file systems. 158eda14cbcSMatt Macy.It Fl v 159eda14cbcSMatt MacyPrint verbose information about the deleted data. 160*c6767dc1SMartin Matuska.El 161eda14cbcSMatt Macy.Pp 162eda14cbcSMatt MacyExtreme care should be taken when applying either the 163eda14cbcSMatt Macy.Fl r 164eda14cbcSMatt Macyor the 165eda14cbcSMatt Macy.Fl R 166eda14cbcSMatt Macyoptions, as they can destroy large portions of a pool and cause unexpected 167eda14cbcSMatt Macybehavior for mounted file systems in use. 168eda14cbcSMatt Macy.It Xo 1697877fdebSMatt Macy.Nm zfs 170eda14cbcSMatt Macy.Cm destroy 171eda14cbcSMatt Macy.Ar filesystem Ns | Ns Ar volume Ns # Ns Ar bookmark 172eda14cbcSMatt Macy.Xc 173eda14cbcSMatt MacyThe given bookmark is destroyed. 174eda14cbcSMatt Macy.El 17516038816SMartin Matuska. 176da5137abSMartin Matuska.Sh EXAMPLES 177da5137abSMartin Matuska.\" These are, respectively, examples 3, 10, 15 from zfs.8 178da5137abSMartin Matuska.\" Make sure to update them bidirectionally 179da5137abSMartin Matuska.Ss Example 1 : No Creating and Destroying Multiple Snapshots 180da5137abSMartin MatuskaThe following command creates snapshots named 181da5137abSMartin Matuska.Ar yesterday No of Ar pool/home 182da5137abSMartin Matuskaand all of its descendent file systems. 183da5137abSMartin MatuskaEach snapshot is mounted on demand in the 184da5137abSMartin Matuska.Pa .zfs/snapshot 185da5137abSMartin Matuskadirectory at the root of its file system. 186da5137abSMartin MatuskaThe second command destroys the newly created snapshots. 187da5137abSMartin Matuska.Dl # Nm zfs Cm snapshot Fl r Ar pool/home Ns @ Ns Ar yesterday 188da5137abSMartin Matuska.Dl # Nm zfs Cm destroy Fl r Ar pool/home Ns @ Ns Ar yesterday 189da5137abSMartin Matuska. 190da5137abSMartin Matuska.Ss Example 2 : No Promoting a ZFS Clone 191da5137abSMartin MatuskaThe following commands illustrate how to test out changes to a file system, and 192da5137abSMartin Matuskathen replace the original file system with the changed one, using clones, clone 193da5137abSMartin Matuskapromotion, and renaming: 194da5137abSMartin Matuska.Bd -literal -compact -offset Ds 195da5137abSMartin Matuska.No # Nm zfs Cm create Ar pool/project/production 196da5137abSMartin Matuska populate /pool/project/production with data 197da5137abSMartin Matuska.No # Nm zfs Cm snapshot Ar pool/project/production Ns @ Ns Ar today 198da5137abSMartin Matuska.No # Nm zfs Cm clone Ar pool/project/production@today pool/project/beta 199da5137abSMartin Matuska make changes to /pool/project/beta and test them 200da5137abSMartin Matuska.No # Nm zfs Cm promote Ar pool/project/beta 201da5137abSMartin Matuska.No # Nm zfs Cm rename Ar pool/project/production pool/project/legacy 202da5137abSMartin Matuska.No # Nm zfs Cm rename Ar pool/project/beta pool/project/production 203da5137abSMartin Matuska once the legacy version is no longer needed, it can be destroyed 204da5137abSMartin Matuska.No # Nm zfs Cm destroy Ar pool/project/legacy 205da5137abSMartin Matuska.Ed 206da5137abSMartin Matuska. 207da5137abSMartin Matuska.Ss Example 3 : No Performing a Rolling Snapshot 208da5137abSMartin MatuskaThe following example shows how to maintain a history of snapshots with a 209da5137abSMartin Matuskaconsistent naming scheme. 210da5137abSMartin MatuskaTo keep a week's worth of snapshots, the user destroys the oldest snapshot, 211da5137abSMartin Matuskarenames the remaining snapshots, and then creates a new snapshot, as follows: 212da5137abSMartin Matuska.Bd -literal -compact -offset Ds 213da5137abSMartin Matuska.No # Nm zfs Cm destroy Fl r Ar pool/users@7daysago 214da5137abSMartin Matuska.No # Nm zfs Cm rename Fl r Ar pool/users@6daysago No @ Ns Ar 7daysago 215da5137abSMartin Matuska.No # Nm zfs Cm rename Fl r Ar pool/users@5daysago No @ Ns Ar 6daysago 216da5137abSMartin Matuska.No # Nm zfs Cm rename Fl r Ar pool/users@4daysago No @ Ns Ar 5daysago 217da5137abSMartin Matuska.No # Nm zfs Cm rename Fl r Ar pool/users@3daysago No @ Ns Ar 4daysago 218da5137abSMartin Matuska.No # Nm zfs Cm rename Fl r Ar pool/users@2daysago No @ Ns Ar 3daysago 219da5137abSMartin Matuska.No # Nm zfs Cm rename Fl r Ar pool/users@yesterday No @ Ns Ar 2daysago 220da5137abSMartin Matuska.No # Nm zfs Cm rename Fl r Ar pool/users@today No @ Ns Ar yesterday 221da5137abSMartin Matuska.No # Nm zfs Cm snapshot Fl r Ar pool/users Ns @ Ns Ar today 222da5137abSMartin Matuska.Ed 223da5137abSMartin Matuska. 224eda14cbcSMatt Macy.Sh SEE ALSO 225eda14cbcSMatt Macy.Xr zfs-create 8 , 226eda14cbcSMatt Macy.Xr zfs-hold 8 227