fix: Fix paperless sync

This commit is contained in:
Benjamin Bädorf 2023-08-29 14:55:25 +02:00
parent 4f26e6f263
commit 4f42b5faff
No known key found for this signature in database
GPG key ID: 4406E80E13CD656C

View file

@ -55,7 +55,7 @@ in {
description = "Directory to sync with."; description = "Directory to sync with.";
type = types.str; type = types.str;
example = "/home/pub_solar/Nextcloud/Paperless"; example = "/home/pub_solar/Nextcloud/Paperless";
default = "/home/${psCfg.user.name}/Paperless"; default = "/home/${psCfg.user.name}/Nextcloud/Paperless";
}; };
}; };
@ -110,16 +110,23 @@ in {
}; };
systemd = let systemd = let
copy-in = pkgs.writeShellScriptBin "copy-in" ''
${pkgs.systemd}/bin/systemctl stop paperless-web.service paperless-task-queue.service paperless-scheduler.service paperless-consumer.service
cp -r ${cfg.sync.directory}/media ${cfg.dataDir}/media
cp ${cfg.sync.directory}/db.sqlite3 ${cfg.dataDir}/db.sqlite3
${pkgs.systemd}/bin/systemctl start paperless-web.service paperless-task-queue.service paperless-scheduler.service paperless-consumer.service
'';
copy-out = pkgs.writeShellScriptBin "copy-out" '' copy-out = pkgs.writeShellScriptBin "copy-out" ''
${pkgs.systemd}/bin/systemctl stop paperless-web.service paperless-task-queue.service paperless-scheduler.service paperless-consumer.service ${pkgs.systemd}/bin/systemctl stop paperless-web.service paperless-task-queue.service paperless-scheduler.service paperless-consumer.service
cp -r ${cfg.dataDir}/media ${cfg.sync.directory}/media cp -r ${cfg.dataDir}/media ${cfg.sync.directory}/media
cp ${cfg.dataDir}/db.sqlite3 ${cfg.sync.directory}/db.sqlite3 cp ${cfg.dataDir}/db.sqlite3 ${cfg.sync.directory}/db.sqlite3
cp ${cfg.dataDir}/celerybeat-schedule.db ${cfg.sync.directory}/celerybeat-schedule.db
cp ${cfg.dataDir}/classification_model.pickle ${cfg.sync.directory}/classification_model.pickle
cp ${cfg.dataDir}/src-version ${cfg.sync.directory}/src-version
${pkgs.systemd}/bin/systemctl start paperless-web.service paperless-task-queue.service paperless-scheduler.service paperless-consumer.service
'';
copy-in = pkgs.writeShellScriptBin "copy-in" ''
${pkgs.systemd}/bin/systemctl stop paperless-web.service paperless-task-queue.service paperless-scheduler.service paperless-consumer.service
cp -r ${cfg.sync.directory}/media ${cfg.dataDir}/media
cp ${cfg.sync.directory}/db.sqlite3 ${cfg.dataDir}/db.sqlite3
cp ${cfg.sync.directory}/celerybeat-schedule.db ${cfg.dataDir}/celerybeat-schedule.db
cp ${cfg.sync.directory}/classification_model.pickle ${cfg.dataDir}/classification_model.pickle
cp ${cfg.sync.directory}/src-version ${cfg.dataDir}/src-version
${pkgs.systemd}/bin/systemctl start paperless-web.service paperless-task-queue.service paperless-scheduler.service paperless-consumer.service ${pkgs.systemd}/bin/systemctl start paperless-web.service paperless-task-queue.service paperless-scheduler.service paperless-consumer.service
''; '';
in mkIf cfg.sync.enable { in mkIf cfg.sync.enable {