How to replicate a zfs pool

Hi all,

I’ve been using truenas scale for a year or so and following the YouTube channel pretty much since day one :grin: but I still consider myself a newbie, so sorry in advance if I misuse a term.
This is the second time I want to move everything to a new pool, the first time I did everything manually but I’m hoping there’s a better way to do it.
I upgraded yesterday to 25.04 with no issues and now I want to create a new pool, move everything from the old pool and delete this other one to repurpose the drives.
I briefly looked online but it seems zfs snd/rec won’t work for me because I don’t have snapshots enabled. Rsync should work to copy the data, but ideally I would like the datasets to be created as well. What’s the best way to do it?

Thanks,
Leo

Give details on your system and your pools. Are you just hosting NAS data or do you have apps and VMs?
It may be as simple as creating a snapshot and doing zfs send/rec.

If you need to post images and such, do the Bot tutorial and browse a few other forum threads to get your trust level up.

TrueNAS-Bot
Type this in a new reply and send to bring up the tutorial, if you haven’t done it already.

@TrueNAS-Bot start tutorial

I have Truenas virtualized on Proxmox, with pcie pass-through for the drives, but no apps or vms inside just the pool with the data.
Forgot to mention that the pools are different, the one where I have the data is a raidz1 with 4 drives and the one I want to create is going to be a mirror with a special vdev mirror.
Can I create a snapshot if I intend to delete the original pool afterwards? I understood snapshots as blocks of data you can reference afterwards.
Thanks

@TrueNAS-Bot start tutorial

I was able to do a replication task for a dataset and it seems to work fine in terms of permissions and so on, but can I delete the data from the origin? because my intention is to replace the pool. Everything I found online about replication is for a backup copy, that’s why I’m unsure.
Thanks in advance

Sorry nobody else has replied. I thought you would get more experienced posts.

You are on the correct path. I have never been through the process so I don’t want to miss anything. Different pool structures shouldn’t matter. Lets see if I can get more advice.

@Stux Sorry to tag you but there haven’t been any other comments and I know you are at least familiar with this process and have helpful videos. Could you point to anyone to ask?

1 Like

It should just be a simple matter of selecting all the datasets, selecting the other pool as a destination and choose Full Filesystem Replication

If you have no snapshots, i think one will be created

A snapshot references data, but when you replicate the snapshot, all the data it references will be copied (if necessary) to the destination.

I wrote a script to clone my Linux OS, which is on ZFS, to alternate boot media, (in case I need it for recovery). This also works as an additional backup. I won’t include the script here because it is highly specialized for copying Linux OS.

Here are the relevant commands:

export MY_SNAP="copy_`date +%H%M%S`"
zfs snapshot -r ${MY_SRC_POOL}@${MY_SNAP}
zfs send  -Rpv  ${MY_SRC_POOL}@${MY_SNAP} | \
  zfs receive -dFu ${MY_DEST_POOL}


zfs destroy -rv ${MY_SRC_POOL}@${MY_SNAP}
zfs destroy -rv ${MY_DEST_POOL}@${MY_SNAP}

Obviously set the source and destination pools, either through the listed environment variables. Or by substituting the text.

Now one point. This was written to perform a full pool copy to an empty destination pool. Not incremental copy, or with existing data on the destination. It is likely the ZFS Receive will work with existing data on the destination pool, as long as that data is not in any of the same named datasets as the source pool uses. YMMV.

@Stux I’ll give it a try, I see that the “full filesystem replication” option is part of the advanced replication task. Thanks!

@Arwen I only intend to do this once to an empty destination pool. If the other process ends up being too complicated, I’ll try this, thanks.

I had to create snapshots of each dataset myself, couldn’t find a way to be done automatically. It’s running now, I’ll report back when it’s done, thanks again!