Post

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.

x



Preparing the TrueNAS Systems

Here we have a dataset named dummy_data on node1 that we will replicate to node2

x

x


On Node2, we have a freshly installed TrueNAS Core system, let’s create a new pool to contain the replicated data

x


We’ll name it helena_backup

x

x


Next on Services, make sure SSH is enabled and login as root is also enabled

x

ZFS Replication uses SSH as the transport layer for replicating dataset



Configuring Replication Task

On node1, go to Replication Task, add new

x


Select the dummy_data dataset inside helena pool for the source location, and the helena_backup pool for the destination

x


Set the schedule, here we set it to run hourly

x


And that should do it, the Replication Task is created

x


ZFS Replication uses snapshot to do replication, therefore when creating replication task, it’ll automatically create a snapshot task that runs with it

x



Running Replication Task

Back on the Replication task on node1, select Run Now to execute the replication task immediately

x


After a while, the state will change to finished

x


Move over to the node2, we can see on helena_backup pool there’s a new dataset created by the replication task

x


The replication task also creates a snapshot for this dataset

x


To easily see the content of a dataset, we can run a shell command and go to “/mnt/helena_backup/dummy_data_backup”

x


To make this dataset available over SMB, let’s enable SMB sharing

x


Now both data are available over SMB

x

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

x


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

x

x


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

x


Set it to only run once

x


Save and wait until the task finishes

x


Now we should see the pulled dataset from node2 created by the replication task, along with its snapshot

x

x


Checking the content with shell, we can confirm that the data has been succesfully recovered

x


This post is licensed under CC BY 4.0 by the author.