ZFS-SNAPSHOT(8)

πŸ’– zfs-snapshot β€” bestie edition πŸ’–

okay so you opened the manual page for zfs-snapshot(8), which lives in the System Manager's Manual section, and honestly? you're about to have the best time. sit down, hydrate, we're making snapshots ✨


🌸 NAME 🌸

zfs-snapshot β€” create snapshots of ZFS datasets 🫢


πŸŽ€ SYNOPSIS πŸŽ€

zfs snapshot [-r] [-o property=value]… dataset@snapname…

like. that's it. that's the whole vibe. look at her πŸ’…


✨ DESCRIPTION ✨

So what this does is: it makes a snapshot of a dataset, OR multiple snapshots of different datasets. multiple. at once. she's efficient, she's organized, she's that girl πŸ‘‘

Now the important part, and I need you to really hear me on this one: snapshots are created atomically. which means a snapshot is a consistent image of a dataset at one specific point in time β€” it captures every modification to the dataset made by system calls that successfully completed before that point in time. no half-finished nonsense, no "oops I caught it mid-write", none of that. clean. pristine. iconic.

and if you use the -r option to make recursive snapshots? they are all created at the same time. every single one of them. no cap. πŸ¦‹

oh and also β€” zfs snap can be used as an alias for zfs snapshot. so if you're feeling lazy (respect), you can just type snap. lowercase bestie behavior, we love it πŸ’œ

if you want the deep lore, go read the "Snapshots" section of zfsconcepts(7). it's giving required reading πŸ“š

  • -o property=value β€” sets the specified property; peep zfs create for the deets on how that works ✨
  • -r β€” recursively creates snapshots of all descendent datasets 🌈

🌟 EXAMPLES 🌟

πŸ“ Example 1: Creating a ZFS Snapshot

This command creates a snapshot named yesterday. That snapshot gets mounted on demand in the .zfs/snapshot directory at the root of the pool/home/bob file system. cute, right?

# zfs snapshot pool/home/bob@yesterday

πŸ“ Example 2: Creating and Destroying Multiple Snapshots

This command creates snapshots named yesterday of pool/home and all of its descendent file systems. each snapshot is mounted on demand in the .zfs/snapshot directory at the root of its own file system. then the second command destroys the brand-new snapshots. we love a full circle moment πŸ’«

# zfs snapshot -r pool/home@yesterday
# zfs destroy -r pool/home@yesterday

πŸ“ Example 3: Promoting a ZFS Clone

these commands show you how to test out changes to a file system and then replace the original file system with the changed one β€” using clones, clone promotion, and renaming. it's a whole glow-up arc, honestly πŸ¦‹

# zfs create pool/project/production
  populate /pool/project/production with data
# zfs snapshot pool/project/production@today
# zfs clone pool/project/production@today pool/project/beta
  make changes to /pool/project/beta and test them
# zfs promote pool/project/beta
# zfs rename pool/project/production pool/project/legacy
# zfs rename pool/project/beta pool/project/production
  once the legacy version is no longer needed, it can be destroyed
# zfs destroy pool/project/legacy

πŸ“ Example 4: Performing a Rolling Snapshot

this example shows how to keep a history of snapshots with a consistent naming scheme. to keep a week's worth of snapshots, the user destroys the oldest snapshot, renames the remaining snapshots, and then creates a new one. like a little conveyor belt of memories πŸŽ€

# zfs destroy -r pool/users@7daysago
# zfs rename -r pool/users@6daysago @7daysago
# zfs rename -r pool/users@5daysago @6daysago
# zfs rename -r pool/users@4daysago @5daysago
# zfs rename -r pool/users@3daysago @4daysago
# zfs rename -r pool/users@2daysago @3daysago
# zfs rename -r pool/users@yesterday @2daysago
# zfs rename -r pool/users@today @yesterday
# zfs snapshot -r pool/users@today

πŸ‘‘ SEE ALSO πŸ‘‘

the whole friend group, fr fr:


okay that's the page!! this one came from OpenZFS, dated July 11, 2022, and yes that date is giving vintage but she ate and left no crumbs πŸ’…βœ¨ go make some snapshots bestie, you got this πŸ«ΆπŸ’–

πŸ“¦ where this page comes from