TrueNAS - ZFS Replication
ZFS Replication is a feature of the TrueNAS storage management system that allows us to create copies of data stored in ZFS file systems and transfer them to another system. It can synchronize data between systems and perform incremental transfers to optimize data replication.
Preparing the TrueNAS Systems
Here we have a dataset named dummy_data on node1 that we will replicate to node2
On Node2, we have a freshly installed TrueNAS Core system, let’s create a new pool to contain the replicated data
We’ll name it helena_backup
Next on Services, make sure SSH is enabled and login as root is also enabled
ZFS Replication uses SSH as the transport layer for replicating dataset
Configuring Replication Task
On node1, go to Replication Task, add new
Select the dummy_data dataset inside helena pool for the source location, and the helena_backup pool for the destination
Set the schedule, here we set it to run hourly
And that should do it, the Replication Task is created
ZFS Replication uses snapshot to do replication, therefore when creating replication task, it’ll automatically create a snapshot task that runs with it
Running Replication Task
Back on the Replication task on node1, select Run Now to execute the replication task immediately
After a while, the state will change to finished
Move over to the node2, we can see on helena_backup pool there’s a new dataset created by the replication task
The replication task also creates a snapshot for this dataset
To easily see the content of a dataset, we can run a shell command and go to “/mnt/helena_backup/dummy_data_backup”
To make this dataset available over SMB, let’s enable SMB sharing
Now both data are available over SMB
by default and for the best, the replicated data on node2 is only available as read-only
Simulating Catastrophic Failure
Now we’re gonna simulate a scenario where we lose everything on node1, and we’re gonna recover the data from node2. To do that let’s delete the helena pool on node1
Now that we no longer has a pool on node1, lets create a new one. This pool will be used to contain the restored data that we pull from node2
Next create a new replication task with the source of node2’s dummy_data_backup dataset and the destination of the newly made helena_recover pool
Set it to only run once
Save and wait until the task finishes
Now we should see the pulled dataset from node2 created by the replication task, along with its snapshot
Checking the content with shell, we can confirm that the data has been succesfully recovered