Get a Quote     (408) 943-4100               TrueNAS Discord      VendOp_Icon_15x15px   Commercial Support Toggle between Light and Dark mode

Creating and Managing Snapshots

  6 minute read.

Last Modified 2022-12-09 09:08 -0500

Snapshots are one of the most powerful features of ZFS. A snapshot provides a read only point-in-time copy of a file system or volume. This copy does not consume extra space in the ZFS pool. The snapshot only records the differences between storage block references whenever the data is modified.

Snapshots keep a history of files and provide a way to recover an older or even deleted files. For this reason, many administrators take regular snapshots, store them for some time, and copy them to a different system. This strategy allows an administrator to roll the system data back to a specific point in time. In the event of catastrophic system or disk failure, off-site snapshots can restore data up to the most recent snapshot.

Taking snapshots requires the system have all pools, datasets, and zvols already configured.

Creating a Snapshot

Consider making a Periodic Snapshot Task to save time and create regular, fresh snapshots.

This short video demonstrates manually adding a snapshot

(Video URL: https://www.truenas.com/docs/files/scaleangelfishmanualsnapshots.mp4)

From the Storage screen you can either and click Snapshots on the top right corner of the screen. Select Snapshots to display the Snapshots screen, or click on the more_vert for the dataset on the Pool Manager screen and select Create Snapshot to take a one-time snapshot of that dataset.

If you don’t have snapshots created, the Snapshots screen displays the Add Snapshots option in the center of the screen.

SnapshotScreenAddFirstSnapshot

  1. Click either Add Snapshots or ADD at the top right of the screen to open the Add Snapshot screen.

    AddSnapshotScreen

  2. Select an existing ZFS pool, dataset, or zvol to snapshot option from the Dataset dropdown list.

  3. Accept the name suggested by the TrueNAS software in the Name field ore enter any custom string to override the suggested name.

  4. (Optional) Select an option from the Naming Schema dropdown list that the TrueNAS software populated with existing periodic snapshot task schemas.
    If you select an option, TrueNAS generates a name for the snapshot using that naming schema from the selected Periodic Snapshot and replicates that snapshot.

    You cannot enter a value in Naming Schema and in Name as selecting or entering a value in Naming Schema populates the other field.

  5. (Optional) Select Recursive to include child datasets with the snapshot.

  6. Click Save to create the snapshot.

Managing Snapshots

The Snapshots screen lists all snapshots created on the system. To manage snapshots, click the expand_more icon to expand the snapshot and display the options for managing that snapshot.

SnapshotScreenExpandedSnapshot

You can display more information in that table by clicking the settings icon. Click Show to display extra columns in the table. To hide the added columns, click the span class=“material-icons”>settings icon again and then click Hide.

Each snapshot entry in the list includes the dataset and snapshot names. Entries also display the snapshot numbers, the space they use, the date the system created them, and the amount of data the dataset can access.

Click expand_more to view snapshot options.

File Explorer he number of snapshots Windows presents to users. If TrueNAS responds with more than the File Explorer limit, File Explorer shows no available snapshots. TrueNAS displays a dialog stating the dataset snapshot count has more snapshots than recommended, and states performance or functionality might degrade.

Deleting a Snapshot

The Delete option destroys the snapshot. You must delete child clones before you can delete their parent snapshot. While creating a snapshot is instantaneous, deleting one is I/O intensive and can take a long time, especially when deduplication is enabled.

ZFS has to review all allocated blocks before deletion to see if another process is using that block. If not used, the ZFS can free that block.

DeleteSnapshotDialog

Click the Delete button. A confirmation dialog displays. Select Confirm to activate the Delete button.

Cloning to a New Dataset

The Clone to New Dataset option creates a new snapshot clone (dataset) from the snapshot contents.

A clone is a writable copy of the snapshot. Because a clone is a mountable dataset, it appears in the Storage screen rather than the Snapshots screen. By default, TrueNAS adds -clone to the new snapshot name when creating the clone.

A dialog prompts for the new dataset name. The suggested name derives from the snapshot name.

CloneSnapshotScreen

Rollback

The Rollback option reverts the dataset back to the point in time saved by the snapshot.

Rollback is a dangerous operation that causes any configured replication tasks to fail.
Replications use the existing snapshot when doing an incremental backup, and rolling back can put the snapshots out-of-order. To restore the data within a snapshot, the recommended steps are:

  1. Clone the desired snapshot.
  2. Share the clone with the share type or service running on the TrueNAS system.
  3. Allow users to recover their needed data.
  4. Delete the clone from Storage.

This approach does not destroy any on-disk data or impact replication.

TrueNAS asks for confirmation before rolling back to the chosen snapshot state. Select the radio button for how you want the rollback to operate.

DatasetRollbackFromSnapshot

Click Confirm to activate the Rollback button.

Deleting with Batch Operations

SnapshotBatchOperationConfirmationt

To delete multiple snapshots, select the left column box for each snapshot to include. Click the Delete button that displays.

To search through the snapshots list by name, type a matching criteria into the Filter Snapshots text field. The list now displays only the snapshot names that match the filter text.

Browsing a Snapshot Collection

Browsing a snapshot collection is an advanced capability that requires ZFS and command-line experience.

All dataset snapshots are accessible as an ordinary hierarchical file system, accessed from a hidden .zfs located at the root of every dataset.

A snapshot and any files it contains are not accessible or searchable if the snapshot mount path is longer than 88 characters. The data within the snapshot is safe but to make the snapshot accessible again shorten the mount path.

A user with permission to access the hidden file can view and explore all snapshots for a dataset from the Shell or the Shares screen using services like SMB, NFS, and SFTP.

In summary, the main required changes to settings are:

  • In dataset properties, change the ZFS properties to enable snapshot visibility.
  • In the Samba auxiliary settings, change the veto files command to not hide the .zfs, and add the setting zfsacl:expose_snapdir=true.

The effect is that any user who can access the dataset contents can view the list of snapshots by going to the dataset .zfs directory. Users can browse and search any files they have permission to access throughout the entire dataset snapshot collection.

When creating a snapshot, permissions or ACLs set on files within that snapshot might limit access to the files.

Snapshots are read-only, so users do not have permission to modify a snapshot or its files, even if they had write permissions when creating the snapshot.

The zfs diff ZFS command, which can run in the Shell, lists all changed files between any two snapshot versions within a dataset, or between any snapshot and the current data.

Related Content