Setting up Periodic Snapshots for VMs in TrueNAS SCALE

atom5ive

Dabbler
Joined
Sep 11, 2023
Messages
17
Hello TrueNAS SCALE Community!

I recently wanted to set up periodic snapshots for my VMs in TrueNAS SCALE, and I found that there isn't a straightforward GUI option to do this. Instead, I had to use the command line interface (CLI) to achieve my goal. I wanted to share the steps I followed, and if you have any alternative methods or suggestions, please feel free to chime in!

Here are the steps to set up periodic snapshots for your VMs using the CLI:

Step 1: SSH into your TrueNAS system and access the CLI.

Step 2: Get the name of the dataset you want to configure. You can get the list of datasets with:


shell

zfs list

Step 3: Set the snapdir property on the dataset. For example:

shell

zfs set snapdir=/mnt/pool1/snapshots dataset1

Step 4: Verify the snapshot directory is set:

shell

zfs get snapdir dataset1

Step 5: Take a snapshot to test it:

shell

zfs snapshot dataset1@testsnap

Step 6: List snapshots and check the location:

shell

zfs list -t snapshot

The snapshot should now be stored in the defined /mnt/pool1/snapshots path.

If you run into any issues setting the custom snapshot directory this way through the CLI, please let me know. The key is using zfs set snapdir= to define the path you want to use for a given dataset.

However, I also discovered that the ability to set a custom snapshot directory per dataset is not exposed in the TrueNAS SCALE UI. The "snapshot directory" and "snapdev" options you see control the visibility of the .zfs snapshot directory but don't allow setting a custom path.

Here are some alternative options:

  1. Set the "Snapshot Directory" on the pool level: You can define the default location for all datasets on that pool by navigating to Storage > Pools > EDIT OPTIONS.
  2. Use the CLI: You can set the "snapdir" property on datasets to the desired path, as mentioned above.
  3. Set the snapshot path in each Periodic Snapshot Task definition: This allows you to define the snapshot location in the task itself.
In summary, the per-dataset snapshot directory can't be set directly in the UI, but it can be controlled in other ways. I appreciate your collaboration in figuring this out, and if anyone knows of an easier method or workaround, please share it with the community. Let's make setting up periodic snapshots in TrueNAS SCALE as user-friendly as possible!

Is all the above information accurate? Please tell me there's an easier way via the GUI to simply define the location of where you want your snapshots to be stored. That's' it. Nothing to crazy.
 

Davvo

MVP
Joined
Jul 12, 2022
Messages
3,222
Looks like a bug, in CORE you can set per-dataset periodic snapshots.
EDIT:
 
Last edited:

atom5ive

Dabbler
Joined
Sep 11, 2023
Messages
17
Looks like a bug, in CORE you can set per-dataset periodic snapshots.
EDIT:
I'm aware of the docs, I read them first before asking here. Also searched th forums as well. The docs only mention snapshoting any pool you want! But never defines where you want to store them. That seems to be set by default. I want to define where they're stored at.
 

Davvo

MVP
Joined
Jul 12, 2022
Messages
3,222
Hello TrueNAS SCALE Community!

I recently wanted to set up periodic snapshots for my VMs in TrueNAS SCALE, and I found that there isn't a straightforward GUI option to do this. Instead, I had to use the command line interface (CLI) to achieve my goal.
Here are the steps to set up periodic snapshots for your VMs using the CLI:
From these and the title of the thread I inferred you were having difficulties in setting up your VM snapshots.

Wanting a different location it's a different thing althogheter.
 

atom5ive

Dabbler
Joined
Sep 11, 2023
Messages
17
From these and the title of the thread I inferred you were having difficulties in setting up your VM snapshots.

Wanting a different location it's a different thing althogheter.
Understood. So... Was a right with the CLI or? Just wanting not to break anything.
 

probain

Patron
Joined
Feb 25, 2023
Messages
211
Out of curiosity, why would you want to have snapshots somewhere special? Feels initially like complexity for complexities sake. But I just might be missing something obvious? :smile:
Let's make setting up periodic snapshots in TrueNAS SCALE as user-friendly as possible!
It's far more user friendly to not actually care where the snapshots are stored per se. But I'm always in favor in giving the user options. So if this was stored behind an "Advanced"-Button. Then sure why not.
 

atom5ive

Dabbler
Joined
Sep 11, 2023
Messages
17
Out of curiosity, why would you want to have snapshots somewhere special? Feels initially like complexity for complexities sake. But I just might be missing something obvious? :smile:

It's far more user friendly to not actually care where the snapshots are stored per se. But I'm always in favor in giving the user options. So if this was stored behind an "Advanced"-Button. Then sure why not.
Because the drive the Hypervisor is on wasn't designed for storage. I have defined drives to store stuff like snapshots & backups on that's are way more protected. The amount of snapshot to VMs will be way more than the Hypervisors OS drive would be able to store. Hence, putting them on a larger, more protected drive.
 
Top