-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
base: master
Are you sure you want to change the base?
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:
|
3be7d20
to
224f1f0
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.
A couple of things that jumped to my eye; mostly nits.
224f1f0
to
bb33fee
Compare
8823606
to
d99b206
Compare
Alright. I've finally mustered up energy to try and wrap this up once more. I went through the whole history and discussion and consistently switched the terminology from backup to export and integrated all suggestions from @Atemu. Some suggestions were outdated by now. And I decided to stick with the pre/post script options. I'm currently fighting that the paperless-ngx package doesn't want to build on master (failing on unit tests)... |
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.
A few improvements and nits but this looks very good to me now.
"no-progress-bar" = true; | ||
"--no-color" = true; | ||
"--compare-checksums" = true; | ||
"--delete" = true; |
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.
I don't think this works with dashes in the names.
This would also get overridden whole when anything is customised which is a bit annoying. The complexity of solving that (i.e. submodule) might not be worth it though.
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.
Yeah, the dashes were a mistake. For some reason I couldn't run the tests yesterday, but they work now. I think was invoking the tests incorrectly and ended up with a wrong package in my environment...
I was expecting the override to be tricky here, too. I'd be happy to switch to a list ... however, the override question still stands. We could split the defaults and keep --no-color
and --no-progress-bar
statically and only put --compare-checksums
and --delete-checksums
in the configurable settings. =
What do you think?
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.
To allow users to override exporter options, set the options value in config
so that they get the standard priority instead of the OptionDefault
priority.
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.
Ah, you mean when using the attrset-based version? And then use the defaultText to show the defaults? What's the idiom to keep those in sync?
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.
In this case, you could use this:
let
defaultExporterOptions = {
no-progress-bar = true;
no-color = true;
compare-checksums = true;
delete = true;
};
in {
options = {
services.paperless = {
exporter.options = lib.mkOption {
defaultText = lib.generators.toPretty {} defaultExporterOptions;
# ...
};
};
};
config = {
services.paperless.exporter.options = defaultExporterOptions;
};
}
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.
@ctheune, yes (with mkOptionDefault
instead of mkDefault
).
Because most importantly, the apply
approach breaks this use case:
# Override all default options
exporter.options = lib.mkForce {
...
}
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.
Yeah that's what my concern was. I had a reply typed out where I also acknowledged that this is more of a theoretical concern (and well beyond bikeshedding I might add), but it didn't send properly due to a spotty internet connection.
As mentioned in the initial comment, I'd be fine if this overrode the default value entirely too; this is polish/bikeshedding.
Especially given that there will hopefully be a proper solution for cases like this soon.
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.
Ok, I'll wrap this up then and hope the shed is sufficiently colorful now. ;)
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.
@ctheune, yes (with
mkOptionDefault
instead ofmkDefault
). Because most importantly, theapply
approach breaks this use case:
Hmm. My test was satisfied with mkDefault
, however, to apply mkOptionDefault
I had to adapt it a bit further and use v.default
instead of v
.
I've committed the current state with mkOptionDefault
.
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.
(You forgot to push.)
211f996
to
e7ee089
Compare
Paperless includes a document exporter that can be used for backups. This extends the module to provide a way to enable and configure a timer, the backup parameters and allow providing a post-processing script (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.
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.
''; | ||
}; | ||
|
||
options = lib.mkOption { |
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.
One last nit: This should probably be called settings
in accordance with RFC42.
default = cfg.dataDir + "/exports"; | ||
defaultText = "\${dataDir}/exports"; |
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.
Nit: Any specific reason this is exports (plural) by default?
I always used export
and was confused by this.
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/
)