Syncoid, by default, does not seem to preserve dataset properties. How can I do this?

Hi everyone, this is my first post on Practical ZFS. Thanks for creating this ZFS discourse site.

I’m testing out sanoid/syncoid so I can make sure I have things figured out properly for my needs, but am running into an issue.

I have 2 testing zpools, each on a separate ssd: tp1 & tp2

Nested datasets are setup in the tp1 pool, under a single main dataset: testdata

I used the following syncoid command to sync tp1 to tp2:

syncoid -r tp1/testdata tp2/testdata

The sync creates all the datasets from tp1 on to pool tp2. I verified that all snapshots were also copied over. Looks good so far. However…

When I compare the dataset properties is when things go wrong. Properties such as compression, encryption & keylocation are not carried over from tp1 to tp2. I figured syncoid would default to exactly copy the dataset, including properties, but that does not seem to be the case.

tp1

(base) john@john-HP-ENVY:~/Documents/temptesting$ sudo zfs list -r tp1 -o name,compression,encryption,keylocation,atime,xattr,mountpoint
NAME                             COMPRESS        ENCRYPTION   KEYLOCATION                   ATIME  XATTR  MOUNTPOINT
tp1                              off             off          none                          off    sa     /zfs/tp1
tp1/testdata                     zstd            aes-256-gcm  file:///etc/zfs/john.key      off    sa     /zfs/tp1/testdata
tp1/testdata/testjohn            zstd            aes-256-gcm  file:///etc/zfs/john.key      off    sa     /zfs/tp1/testdata/testjohn
tp1/testdata/testjohn/testdata   zstd            aes-256-gcm  file:///etc/zfs/john.key      off    sa     /zfs/tp1/testdata/testjohn/testdata
tp1/testdata/testjohn/testemail  off             aes-256-gcm  file:///etc/zfs/john.key      off    sa     /zfs/tp1/testdata/testjohn/testemail
tp1/testdata/testjohn/testhome   zstd            aes-256-gcm  file:///etc/zfs/john.key      off    sa     /zfs/tp1/testdata/testjohn/testhome
tp1/testdata/testpictures        off             aes-256-gcm  file:///etc/zfs/pictures.key  off    sa     /zfs/tp1/testdata/testpictures
tp1/testdata/testsusan           zstd            aes-256-gcm  file:///etc/zfs/susan.key     off    sa     /zfs/tp1/testdata/testsusan
tp1/testdata/testsusan/testhome  zstd            aes-256-gcm  file:///etc/zfs/susan.key     off    sa     /zfs/tp1/testdata/testsusan/testhome

tp2

(base) john@john-HP-ENVY:~/Documents/temptesting$ sudo zfs list -r tp2 -o name,compression,encryption,keylocation,atime,xattr,mountpoint
NAME                             COMPRESS        ENCRYPTION   KEYLOCATION  ATIME  XATTR  MOUNTPOINT
tp2                              off             off          none         off    sa     /zfs/tp2
tp2/testdata                     off             off          none         off    sa     /zfs/tp2/testdata
tp2/testdata/testjohn            off             off          none         off    sa     /zfs/tp2/testdata/testjohn
tp2/testdata/testjohn/testdata   off             off          none         off    sa     /zfs/tp2/testdata/testjohn/testdata
tp2/testdata/testjohn/testemail  off             off          none         off    sa     /zfs/tp2/testdata/testjohn/testemail
tp2/testdata/testjohn/testhome   off             off          none         off    sa     /zfs/tp2/testdata/testjohn/testhome
tp2/testdata/testpictures        off             off          none         off    sa     /zfs/tp2/testdata/testpictures
tp2/testdata/testsusan           off             off          none         off    sa     /zfs/tp2/testdata/testsusan
tp2/testdata/testsusan/testhome  off             off          none         off    sa     /zfs/tp2/testdata/testsusan/testhome

How to I change “syncoid -r tp1/testdata tp2/testdata” so that tp2 becomes an exact duplicate of tp1, including the properties?

Thanks in advance for any help.

John

(By the way, please ignore the red & green highlighting in the tp2 section above. I used preformatted text option in all those sections and for some reason the last one got all the random red & green highlighting.)

Reading through some other discussions I found the --sendoptions=wp option mentioned.

syncoid --sendoptions=wp -r tp1/testdata tp2/testdata

That appears to have sorted my issues out, as far as I can tell.

Is that the proper way to get an exact duplicate (while preserving properties) copied over to the backup pool? Any other syncoid options that should be used in addition or in place of these?

1 Like

Technically speaking, that’s not a syncoid option, it’s a zfs send option.

What you’re doing there is passing two extra arguments to zfs send: -w and -p. The -p argument is to Preserve dataset/zvol properties, and the -w argument is for “raw send”.

All you really needed here for your stated goal, AFAIK at least, is --sendoptions=p to pass through the Preserve properties option. Raw send is mostly used for compressed or encrypted data: without that argument, zfs send first decompresses and/or decrypts data prior ro sending it. With that option, zfs send pipes the data along exactly as-is.

Syncoid is pretty severely conservative by design, which is why those are not the default options: they aren’t the default in zfs send, and they aren’t the default here, either. I think there’s an argument to be made that raw send and property preservation should be the default behavior of zfs send, but I think the place to legislate that is in the OpenZFS project itself.

Syncoid’s job is to stay out of the way as much as possible, while enabling an rsync-like experience not otherwise possible with the raw ZFS toolset. I think it’s important to enable as much of that raw toolset’s functionality as possible, which is why we have arguments in syncoid to pass arguments through directly to both zfs send and zfs receive–if OpenZFS can do it, I want syncoid to let you do it too. But I also think it’s not syncoid’s job to make the defaults different than OpenZFS’s defaults, which is why we aren’t (and almost certainly won’t) make passing -w and -p down to zfs send the default behavior.

Thanks for that detailed explanation.

Makes sense to keep the defaults the same as the OpenZFS defaults. Metaphorically, the default might be like mailing a book from one location to another. But when the book arrives the book is no longer bound, cover is separated and all the pages are loose but in order. Still all the same info & organized, just not held together in the same way. My guess is that most end users would expect for the copy to be an exact duplicate of the original, including preserving properties, but I imagine the original zfs project likely had a good reason for doing it the way they did. No need to dive deep into this, though, as the sendoptions seem to have sorted this stuff out nicely for me.

Just out of curiosity, I did some quick testing of --sendoptions=p with & without -w. -wp seems to be mandatory when there are encrypted datasets and optional without encrypted datasets. Compression seems to copy over whether or not -w is used.

As long as --sendoptions=wp gets me an exact copy of everything, including any other dataset properties, that works for me. :slight_smile:

Thanks for your help & for creating sanoid/syncoid.

1 Like