
Taking Snapshot of Virtual Machines are an easy way of saving the current state of a virtual machine. It’s not equivalent of having a full backup, but a great tool when you want to try out some new configuration without risking to break everything beyond repair.
Take a Snapshot
To take a manual snapshot, navigate to Storage > Snapshots > ADD
Choose the dataset you want to snapshot (The Virtual Machine Image)
Modify the name if you want
Click Submit
Note: The VM can be turned on or off. It should not matter but may depend on the type of applications running.
Rollback the Snapshot
Let’s make a small change inside the VM:
sudo nano /etc/hosts
Before:
127.0.0.1 localhost
...
After:
127.0.0.1 localhost localhost.local
...
To rollback the changes made, we need to first poweroff the machine:
sudo halt --poweroff
Storage > Snapshots > click the 3 dots to the left on your snapshot and click Rollback
Power on the VM and then verify that the changes in /etc/hosts are reverted:
sudo nano /etc/hosts
127.0.0.1 localhost [aaand it's gone!]
...
Source: https://www.truenas.com/community/threads/snapshot-virtual-machines.99817/
Delete the Snapshot
Let’s delete the snapshot and start over from a clean slate before proceeding with the next task.
Schedule Periodic Snapshots
You can configure cron jobs to take periodic snapshots of all your VMs.
Go to Tasks > Periodic Snapshot Tasks > ADD
Settings:
Dataset is set to the parent directory for all VMs. Recursive means it will take snapshot of all datasets underneath it.
Snapshot Lifetime is set to 3 Weeks
Schedule is set to once a week. That means that there won’t exist more than 3 versions for each VM.
I don’t recommend changing the Naming Schema too much. It is apparently very picky with the syntax.
Click Submit
Source: https://www.truenas.com/community/threads/scheduled-periodic-snapshot-tasks-never-happen.94050/
Trigger a Scheduled Snapshot
Now we can either wait until Sunday night to find out if the configuration is working, or we can trigger a snapshot right now under Storage > Snapshots > ADD
Settings:
Dataset is set to the VM directory with recursive setting on, just like in the scheduled snapshot.
Remove the name and use the Naming Schema instead of the scheduled snapshot created earlier
Submit
Conclusion
TrueNAS have a very useful GUI. As I’m learning Linux Server Administration I realize how easy TrueNAS makes certain tasks to be, for the most part. TrueNAS is becoming one of my favorite Open Source Server softwares.