-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
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
Provide NixOS module option to enable the paperless exporter. #242084
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are fixups for your first commit, which should definitely be merged.
Maybe add a dedicated PR because these changes are orthogonal to backups and entirely uncontroversial.
The term Also, the export command used by the backup service creates redundant copies of each doc in multiple formats, which is also not suitable for backups. |
Well it is what is recommended as the official backup strategy according to the manual. It also seems comprehensive with the metadata. I can see all the table content like tags, correspondents, users, even saved filters and UI settings ...
That is configurable using the command parameters that I've made adjustable. |
Thanks for those. I'll double check (and I guess I should add a test) that the quoting works both for systemd and the manage command now. |
Ah right, the metadata is exported to
These should be fixed so that no redundant content is exported by default. I'm still not convinced that paperless needs a dedicated backup service. It can be generically backed up like many other database-based NixOS services: Either by (1) snappshotting and transfering the whole of |
There's no quoting involved when setting up the systemd env, so this has always worked correctly. Line 482 in 189a069
|
That is what we're doing, but with ZFS snapshots of the data dir. |
I think there are two different use-cases for backups:
1 can probably just be handled by backuping postgresql + the paperless state dir. Probably i would still, even if this feature was available, just make a backup in the style of 1. But I can also understand why people (probably @ctheune) may think different. |
The export service just boils down to this simple snippet, which we could simply add to the NixOS manual: { config, ... }:
let
paperless = config.services.paperless;
in
systemd.services.paperless-export = {
startAt = "daily";
serviceConfig = {
User = paperless.user;
ExecStart = ''
${paperless.dataDir}/paperless-manage document_exporter <export_dir> --no-progress-bar --no-color --compare-checksums --delete
'';
};
}; |
@Atemu, maybe let's first decide if or in what form we want to include this. |
Thanks. I've created #243084 for the orthogonal changes. |
Alright. I'm happy to follow pretty much most of the suggestions, but as the PR itself is still under question, I'll postpone that. Having to take paperless offline was something I overlooked and I guess the exporter could arrange for that. Whether to include it, I see the following parts that need discussion:
|
211f996
to
e7ee089
Compare
e7ee089
to
ed36619
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Migrated my config over to this and it was a breeze.
ed36619
to
916c9e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The module and the test are broken. Fixups.
Fetch with:
git fetch https://github.com/erikarvstedt/nixpkgs paperless-backup-master-ea-4
git log ..FETCH_HEAD
Further remarks. Medium prio, so ignore if you want to get this merged fast:
I agree with @Atemu that pre/postScript
is redudant. There are many ways to achieve this without extra options, most notably so:
systemd.services.paperless-exporter = {
preStart = "...";
postStart = "...";
}
Also, like @Atemu mentioned before, needless log output is annoying and doesn't fit the style of other NixOS services.
The exporter prints Running pre/post script
even when no pre/post script is run. We should remove this kind of output entirely.
When using pre/postStart = "...";
, systemd always shows which stage is currently running and the log shows the offending stage on failures. So diagnosability is fine.
Ugh, dang. Apparently I didn't run the tests after my last changes - sorry, that was bad form on my side. Although I did run the test when twiddling the v.default stuff and that did fulfill the test ... if it did that by accident, then I'll need to revisit that test. I'll pick up your changes and double check that. I'll remove the pre/post options. [Edit]: Note that I'm personally still on the fence with the pre/post stuff. I guess I dislike splitting up those units of execution in an IMO clobbered way over multiple scripts. I know we rely endlessly on systemd, but it still feels clunky, especially if you want to run things manually for development/debugging. [Edit]: I'm still removing the pre/post script stuff, but please note that it doesn't provide the diagnosability things as I mentioned: it does show the stage when it breaks. It doesn't show the stage if it's silent and gets stuck, so there's also no info how long steps take ... but I guess that's something everyone can put in their pre/post scripts if they want to see this. (Except being able to see the moment when the actual export starts because the unit start log entry will reflect when the unit is started, not when the main process starts) |
Paperless includes a document exporter that can be used for e.g. backups. This change extends the module to provide a way to enable and configure a timer, export settings, pre- and post-processing scripts (e.g. to ship the backup somewhere else, clean up, ...). It works out of the box when just enabling it but can be customized. Includes suitable tests.
916c9e3
to
865ab91
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for your patience!
I did run the test when twiddling the v.default stuff and that did fulfill the test
Weird, v.default
will always error when evaluating the module, regardless of what config options are used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again! LGTM
And sorry for not testing correctly @erikarvstedt
@@ -82,7 +82,7 @@ let | |||
}; | |||
in | |||
{ | |||
meta.maintainers = with lib.maintainers; [ leona SuperSandro2000 erikarvstedt ]; | |||
meta.maintainers = with lib.maintainers; [ leona SuperSandro2000 erikarvstedt atemu theuni ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So many maintainers will probably just diverge responsibility and in the end no one feels really responsible.
…fault value into config to aid future problems
Description of changes
Integrate the paperless document exporter as a backup feature into the module.
Also fixes a configuration (quoting) issue.
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)