ZFS how to copy a whole zpool?

brutalizer

[H]ard|Gawd
Joined
Oct 23, 2010
Messages
1,602
How do you copy a whole zpool to another zpool? I see there is a command zfs clone, and I can also use zfs send | receive. How do you copy a whole zpool? I was thinking of something like:

# zfs snapshot -r tank@fullbackup
# zfs send -R tank@fullbackup | pv | zfs receive -vFd myBackupPool
# zfs destroy -r tank@fullbackup

And what arguments do you use?

EDIT: and then myBackupPool will contains lot of new filesystems, each having a snapshots called "fullbackup" so I need to delete these snapshots afterwards. And after that step, I will have a complete duplicate of "tank" - right?

"pv" monitors the progress
 
Last edited:
Hmmm.... I have a problem here.

I have created a new empty "myBackupPool" and mounted it under "/mnt", so the path is now "/mnt/myBackupPool".

After that, I copied the whole old pool "/mnt/tank" via "zfs send | receive" to the new backup pool.

Here is the problem: the "myBackupPool" is mounted on the same mount point as the old "tank". When I do "zfs list" I get:

tank is mounted on "/mnt/tank"
myBackupPool is mounted on "/mnt/tank"

So we see that both are mounted on the same mount point. Why is that, and how do I solve this problem? What do you suggest?



EDIT: it seems that "-u" solves this problem. So "zfs receive -u" does not mount the new pool on the same mount point. So the syntax should be like this:

# zfs snapshot -r tank@fullbackup
# zfs send -R tank@fullbackup | pv | zfs receive -vFdu myBackupPool
# zfs destroy -r tank@fullbackup



EDIT 2: as the new pool is mounted ontop the old pool, I export and import the new pool again like this:
# zpool export myBackupPool
# zpool import -R /mnt/myNewBackupPool myBackupPool
This fixes the problem of both pools being mounted on same mount point. Using the "-u" flag should have corrected this problem.

But because I forgot the "-d" flag on "zfs receive", the mount point of the new pool is not really correct as it looks like this:
# zfs list
/mnt/myNewBackupPool/mnt/myBackupPool
i.e. the mount points are nested. I suspect the "-d" flag corrects this deeply nest.

EDIT3: Strange. After copying, the new zpool is trying to mount ontop of the old filesystems which fail. So I need to export the old pool, remount the new pool to a new directory and mount all filesystems, and then import the old pool to it's old place.
# zfs mount -a
fails to mount the new pool, because the old pool is in the way, it tries to mount all new filesystems in the new pool, in the same path as the old pool
# zpool export oldpool
# zfs set mountpoint=/newPath newpool
# zfs mount -a
succeeds to mount the new pool, because it mounts everything in the newPath
# zpool import oldpool
 
Last edited:
Back
Top