Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syncoid: systemd.unit + debian #886

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

crpb
Copy link

@crpb crpb commented Feb 11, 2024

Hi,

as i was writing a systemd.service/time because in the 'Issues' people only said they created them but didn't share anything about it and so i began to try out a couple few things how this could be realized in a good way.

Well, it isn't finished, or rather not what it could be, but at least it works for a simple one-to-one synchronization for now.

And in that process as i'm using Debian and wanted to build/install to check if that works as expected i also did a bit of work in the debian-folder. Tho i haven't upgraded the Packaing-Version or format. But at least i could remove all those directives in the debian/rules

I think log's say more than a thousand words 🙈

% dpkg-deb --contents ../sanoid_2.2.1_all.deb
drwxr-xr-x root/root         0 2023-02-10 22:15 ./
drwxr-xr-x root/root         0 2023-02-10 22:15 ./lib/
drwxr-xr-x root/root         0 2023-02-10 22:15 ./lib/systemd/
drwxr-xr-x root/root         0 2023-02-10 22:15 ./lib/systemd/system/
-rw-r--r-- root/root       312 2023-02-10 22:15 ./lib/systemd/system/sanoid-prune.service
-rw-r--r-- root/root       272 2023-02-10 22:15 ./lib/systemd/system/sanoid.service
-rw-r--r-- root/root       124 2023-02-10 22:15 ./lib/systemd/system/sanoid.timer
-rw-r--r-- root/root       387 2023-02-10 22:15 ./lib/systemd/system/syncoid.service
drwxr-xr-x root/root         0 2023-02-10 22:15 ./usr/
drwxr-xr-x root/root         0 2023-02-10 22:15 ./usr/sbin/
-rwxr-xr-x root/root      3988 2023-02-10 22:15 ./usr/sbin/findoid
-rwxr-xr-x root/root     59062 2023-02-10 22:15 ./usr/sbin/sanoid
-rwxr-xr-x root/root     79605 2023-02-10 22:15 ./usr/sbin/syncoid
drwxr-xr-x root/root         0 2023-02-10 22:15 ./usr/share/
drwxr-xr-x root/root         0 2023-02-10 22:15 ./usr/share/doc/
drwxr-xr-x root/root         0 2023-02-10 22:15 ./usr/share/doc/sanoid/
-rw-r--r-- root/root        92 2023-02-10 22:15 ./usr/share/doc/sanoid/README.Debian
-rw-r--r-- root/root      6842 2023-02-10 22:15 ./usr/share/doc/sanoid/README.md.gz
-rw-r--r-- root/root       632 2023-02-10 22:15 ./usr/share/doc/sanoid/TODO
drwxr-xr-x root/root         0 2023-02-10 22:15 ./usr/share/doc/sanoid/changelog/
-rw-r--r-- root/root      6721 2023-02-10 22:15 ./usr/share/doc/sanoid/changelog/CHANGELIST.gz
-rw-r--r-- root/root      2114 2023-02-10 22:15 ./usr/share/doc/sanoid/changelog/dh_installchangelogs.dch.trimmed.gz
-rw-r--r-- root/root      1134 2023-02-10 22:15 ./usr/share/doc/sanoid/copyright
drwxr-xr-x root/root         0 2023-02-10 22:15 ./usr/share/doc/sanoid/examples/
-rw-r--r-- root/root      3945 2023-02-10 22:15 ./usr/share/doc/sanoid/examples/sanoid.conf
-rw-r--r-- root/root      1266 2023-02-10 22:15 ./usr/share/doc/sanoid/examples/syncoid.conf
-rw-r--r-- root/root       267 2023-02-10 22:15 ./usr/share/doc/sanoid/examples/syncoid.timer
drwxr-xr-x root/root         0 2023-02-10 22:15 ./usr/share/man/
drwxr-xr-x root/root         0 2023-02-10 22:15 ./usr/share/man/man8/
-rw-r--r-- root/root       498 2023-02-10 22:15 ./usr/share/man/man8/findoid.8.gz
-rw-r--r-- root/root       863 2023-02-10 22:15 ./usr/share/man/man8/sanoid.8.gz
-rw-r--r-- root/root      2322 2023-02-10 22:15 ./usr/share/man/man8/syncoid.8.gz
drwxr-xr-x root/root         0 2023-02-10 22:15 ./usr/share/sanoid/
-rw-r--r-- root/root      4685 2023-02-10 22:15 ./usr/share/sanoid/sanoid.defaults.conf

The manpages were created with. Maybe this could be done with a Makefile instead?

help2man -N -s 8 -o findoid.8 /usr/sbin/findoid
help2man -N -s 8 -o syncoid.8 /usr/sbin/syncoid
help2man -N -s 8 -o sanoid.8 /usr/sbin/sanoid

syncoid.service will only work with a existant /etc/sanoid/syncoid.conf but will not spew out any errors if it isn't configured.

syncoid.conf has a bunch of comments on how and why i did it like that.
i wondered while i was trying out some things if it wouldn't be better to have syncoid parse an actual configfile like sanoid does which will also allow non-systemd users to make use of it? 🙊

PS: i suppose this can PR can be worked on a while as i'm not totaly happy with it but maybe someone else has a good idea and thats why i stopped here for now 🙉

Cheers

@jimsalterjrs
Copy link
Owner

@phreaker0 are you a systemd person? I don't ever use systemd timers, so I don't feel entirely comfortable dogfooding this one. But if we can get a couple independent confirmations that it's good, seems like it would be a nice thing to go ahead and merge.

@bjodah
Copy link

bjodah commented Mar 14, 2024

So I'm just getting started using sanoid, and saw this PR so I thought I should give it a go.
After building the .deb and installing it using apt, I was somewhat surprised that the folder /etc/sanoid wasn't created. Fair enough, I created it and crafted a sanoid.conf for my taste. I tried running sanoid:

# TZ=UTC sanoid --take-snapshots --verbose
FATAL: cannot load /etc/sanoid/sanoid.defaults.conf - please restore a clean copy, this is not a user-editable file! at /usr/sbin/sanoid line 880.

I can see that this PR installs the sanoid.defaults.conf file under /usr/share/sanoid/ instead, am I supposed to move copy this file to /etc/sanoid/?

Doing allows the command to finish successfully.

Moving on to configure syncoid I look for a syncoid.conf file, but I cannot find one in neither /etc/sanoid nor /usr/share/{sanoid,syncoid}. Looking at the diff in this PR I think it looks like the example config is not really copied by the install script?

And finally, I wanted to enable the systemd services. I'm not terribly familiar with systemd yet, but shouldn't one be expected to find the services listed by this command?

# systemctl list-units --all | grep -E '(sanoid|syncoid)'
#

Forgive any misconceptions on my part, I'm not terribly proficient with systemd, to say the least. Thank you for working on this!

EDIT: also, the --include-datasets= option referred to in syncoid.conf looks... undocumented?

@phreaker0
Copy link
Collaborator

@bjodah this PR removes the install of /etc/sanoid, I don't know why and it obviously breaks stuff. You can use the latest master/release version to build your deb.

@crpb IMHO there shouldn't be a shipped system service/timer for syncoid, as replication will in most cases be more specific which can't be covered by a single src/target setup. I for example have serveral replication timers/services for may different pools and hosts. Furthermore replication shouldn't be tied to sanoid-prune by default.
But a documented example for a systemd service/timer would be nice.

@crpb
Copy link
Author

crpb commented Mar 16, 2024

@phreaker0

this PR removes the install of /etc/sanoid, I don't know why

thats because i took a few parts from the package in debian. the config isn't shipped by default and is only mentioned in the README.Debian. and i didn't realize that removing it from rules will do that 🙃

  • mark /etc/sanoid/sanoid.conf as conffile again

there shouldn't be a shipped system service/timer for syncoid, as replication will in most cases be more specific

yeah, it was a first trial. also see those remarks which would probably end in a much more complex thing.
i don't realy have enough case examples i could come up with as i only use it for my workstation, laptop and one rootserver. the other zfs-driven systems i have are truenas which obviously don't have any need for sanoid 👀

  • syncoid.service -> examples

Furthermore replication shouldn't be tied to sanoid-prune

with my first tests i had a timer like in the example running but wasn't 100% if that could messy if both sanoid and syncoid start on the same time so i later hooked it to sanoid-prune which, for my simple replicationscheme, works so far.

  • untie syncoid.service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants