ZFS Snapshots: Instant Data Recovery in Seconds on Linux

Published: November 5, 2025 | Duration: 3:24

Learn how to create and use ZFS snapshots for instant data protection and recovery on Linux. This tutorial demonstrates the complete process of creating snapshots, simulating data loss, and performing instant recovery using ZFS rollback commands.

What you’ll learn in this video:

  • How to verify your ZFS pool status and configuration
  • Creating instant snapshots with the zfs snapshot command
  • Listing and verifying your ZFS snapshots
  • Simulating accidental data loss or corruption
  • Performing instant recovery with zfs rollback
  • Understanding ZFS snapshot naming conventions

ZFS snapshots provide point-in-time copies of your datasets without consuming significant disk space initially. They’re perfect for protecting against accidental deletions, file corruption, or testing changes before committing them permanently.

📝 Video Transcript

00:00 – Introduction
Welcome to linuxconfig.org. In this tutorial, you’ll learn how to create and use ZFS snapshots for instant data protection and recovery. We’ll demonstrate creating a snapshot of a ZFS dataset, making changes to files, and then rolling back to restore the original state in seconds. Let’s get started.

00:32 – Checking ZFS Configuration
Before we can create snapshots, we need to verify our ZFS pool configuration and check our existing datasets. First, we’ll use zpool dash dash version to confirm ZFS is installed and check the version. Then we’ll run zpool status to verify our pool named ZFS pool is online and see that it’s using disk SDB. Next, we’ll use ZFS list to view our datasets, including the linuxconfig dataset mounted at slash zfspool slash linuxconfig. Keep in mind, your output will be different depending on your specific ZFS setup, pool names, and disk configuration.

01:14 – Creating Test Files
Now, let’s navigate to our dataset and create some test files. We’ll change directory to slash zfspool slash linuxconfig using the cd command. First, we’ll run ls to confirm the directory is empty. Then we’ll create two sample files, file1.txt with the content original content and file2.txt with important data using the echo command. We’ll use ls dash lh to view our newly created files with human readable file sizes. You can see both files are around 15 to 17 bytes in size and were created on November 5 at 8.22. Finally, we’ll use cat asterisk. This shows us original content from file1.txt and important data from file2.txt. These files will serve as our test data before we create the snapshot.

02:17 – Creating the Snapshot
Now we’ll create our first ZFS snapshot. We use the command sudo zfs snapshot followed by the dataset name and snapshot name separated by an at sign. In this case, we’re creating a snapshot of zfspool slash linuxconfig at backup1. The at sign is crucial as it separates the dataset name from the snapshot name. This command executes instantly, creating a point-in-time copy of our dataset without consuming significant disk space initially. The snapshot named backup1 now preserves the exact state of our files at this moment.

02:59 – Verifying the Snapshot
Let’s verify our snapshot was created successfully, using zfslist dash tsnapshot. We can see our snapshot zfspool slash linuxconfig at backup1 is listed, currently using zero bytes and referencing 25 kilobytes of data.

03:21 – Simulating Data Loss
Now let’s simulate a data disaster by modifying and deleting our files. We’ll overwrite file1.txt with wrong content and completely remove file2.txt using the rm command. Running ls-lh shows only file1.txt remains, now containing our incorrect data. The cat command confirms we’ve lost our important data and corrupted our original content.

03:56 – Performing Recovery
Here’s where ZFS snapshots shine. Instant recovery with a single command. We use sudo zfs rollback followed by our snapshot name zfspool slash linuxconfig at backup1. Running ls-lh immediately shows both files are back with their original timestamps from 8.22. The cat command confirms everything is restored. Original content and important data are back exactly as they were. In just seconds, we’ve completely recovered from data loss without any complex restoration procedures. Subscribe for more Linux tutorials and thanks for watching.