A high-level NixOS module for Nextcloud

I wrote a wrapper for the NixOS nextcloud module that includes backup / restore scripts, automatically requesting certificates from Let’s encrypt and a few other improvements for people (like me) who just want to get a reasonably set up nextcloud instance with as little configuration as possible. In case anyone else finds this useful, I created a flake for it:

In case you find any issues or have suggestions for improving it, please let me know!

4 Likes

I think it makes a lot of sense to upstream the backup scripts as it seems pretty much agnostic of the backup solution and can be useful for anyone using the lower level NixOS module (as I do have my own high level mechanisms).

But the backup/restore scripts is neat! Did you test it, how do you test it? I think it’d be crazy good to have tested backup&restore in NixOS upstream. :slight_smile:

4 Likes

Thanks, the backup & restore were also the main part of the effort. I tested them by creating a new nextcloud instance, changing some stuff (uploading files, etc.), invoking the backup script, nuking the instance (rm -rf /var/lib/nextcloud), setting up nextcloud again and then calling the restore script. It would be nice to automate this (NixOS contains quite a few automated tests if I remember correctly), but I don’t know how to do this. In particular, it seems non-trivial to automatically check whether all the state of a nextcloud instance has been restored and whether the instance is working correctly. I also used the restore script to migrate my personal nextcloud from snap but that included some manual renaming since the output formats differ.

Upstreaming it into NixOS would be nice if contributions like this are accepted (the scripts are a bit opinionated but maybe they’re helpful for enough people that it makes sense including them). The backup currently only works for MySQL, so to merge it into NixOS the other database types should probably be supported as well. I’ll have a look at that if I find some time.

I’ve improved the backup & restore scripts a bit more and created a PR to add them to the NixOS nextcloud module. They now work with all 3 database types and are automatically tested in a few NixOS integration tests. I’d appreciate any suggestions / reviews in case anyone wants to take a look at it.

1 Like