Skip to content

202504032226 Migrate Nextcloud via Kubernetes

DRAFT

Tips

  1. Use the helm chart – it feels a lot easier but there are limitations
    1. +ve -> handle the permissions for you and all the hidden chown shenanigans
    2. -ve no configMapRef so it’s a bit annoying that I cannot mount an entire configMap in. I probably can but I need to dig deeper.
  2. Use Longhorn NFS for the PV/PVC for the non-data folders. NFS via Truenas Share has an issue where its synchronous and painful. Using a NFS V4 share via Truenas takes 1 hour for the initialisation to occur.

Migration Steps

Follow most of the migration steps here but for brevity sake and future documentation, here is what it roughly looks like

  1. Startup the new nextcloud instance but don’t log in or do anything.
    1. Ensure ingresses are done right an your ingress controller can route the traffic for https to your preferred domain name and TLS can be terminated.
  2. Scale the replica to 0.
  3. Nuke the new postgres database and re-create it with the same name.
  4. Move the /data NFS share dir into a new NFS share
    1. The reason I did this was because i wanted the old NFS share to not be overwritten. I could, theoretically use the same old share but I’d like to be safe than sorry.
  5. Do a db dump
    1. I moved from mariadb(mysql) to postgres. I used pgloader and wrote a script that looks to load it from mariadb to postgres
  6. After the db dump is done, I had to rename my schema from mariadb to public in the new postgres db
  7. Once the data is transferred into the NFS share intended to store the data for the nextcloud deployment as a NFS PV/PVC, spin up a single replica instance.
  8. You’ll get errors namely as a consequence of the db dump. Update these fields in config.php found in /config dir.
    1. Incorrect db user name
    2. Incorrect db password
    3. Missing overwrite.cli.url for trusted CLI url
    4. Missing overwriteprotocol for HTTPS
  9. You can cp the folder from the pod locally and the cp back. The reason I did this was the lack of an editor in the nextcloud pod.
    1. After cp the new config.php you’ve edited into the pod, nextcloud app won’t be able to read it due to user permissions. Run this chown command chown -R www-data:www-data config.php in the pod
    2. Rollout restart the pod
  10. You will need to do an upgrade
    1. In the pod run su -s /bin/sh www-data -c "php occ upgrade"
  11. The upgrade should start to run
  12. Go to your nextcloud.yourdomain.com aaaaand voila!