#PaperlessNGX on #NixOS crisis averted. 😎

An accidental update from SQLite to PostgreSQL looked like it lost all my documents 😱

`nixos rebuild switch` was not behaving consistently and a build where I had added the `database.createLocally = true;` was added after a successful build, so it didn't actually run PostgreSQL. In desperation, I did an overdue upgrade to NixOS 25.11 and it worked, but I had dozens of documents loaded and when it rebuilt, it found and used that new option...

1/2

So, I rolled back to the previous generation, but the upgrade used a newer Redis version and changed the db storage format, so the older version could not read it, and paperless would not fully start 🤬

Solution:

1. Reboot to latest generation,
2. Removed the option in situ,
3. `nixos-rebuild test`
4. `paperless-manage document_exporter export`
5. Reboot to latest generation,
6. `paperless-manage document_importer export`
7. Login to see all documents 😬
8. restore configuration.nix

2/2

@mcrocker That is scary. I do not like using database type progs for data storage.

@adingbatponder Well, Paperless-NGX keeps the original documents in their original format in a separate directory, and only keeps meta-data in the database, but it was still a pain to have to use the old set-up to export the data to a back-up and then go back to the new setup to import it.

The good thing is that NixOS makes that sort of thing trivial, but the obvious trivial way didn't work due to weird version issues, so I had to go for a slightly non-obvious way that may not have worked.

@mcrocker Sounds great. Sounds like if I try this package I will pin all dependencies to protect them from updates that break things. I have had horrible experiences using flake -update which has a massive blast radius. So anything important is pinned now and has to be deliberately, manually, individually updated... often very very late because one forgets.