Migrate existing Nextcloud

I have an existing nextcloud server running on a Raspberry Pi that I would like to move to my main server machine which is running NixOS. Can I just replace /var/lib/nextcloud with the old one and restore the db from backup? How do I even connect to the nextcloud database under nixos?

I haven’t tried it myself but I’m pretty sure that should work. Just make sure you’re migrating to the same version of Nextcloud and database type that you have now.

Check out these options for configuring the Nextcloud database.

If you leave them alone, Nextcloud will create a sqlite DB for you. If you change dbtype, Nextcloud will expect to connect to an existing database with dbhost, dbuser, dbport, dbname, dbpassFile (unless you set services.nextcloud.database.createLocally).