Ubuntu – nextcloud snap with data-directory on external harddrive


I installed nextcloud on my raspberrypi 3 using this link. Everything is working pretty well except I don't like the UX of having all the extra storage space coming from the "External Storage" add-in, since it means that everyone now has to know to put all of their files in a designated folder.

It seems like I should just be able to tell nextcloud to use the external harddrive as the data-directory location (without the external storage add-in) and all will be well and good… and it seems like in theory that works fine. But, since it's installed as a snap, it seems like the snap doesn't have access to that part of my filesystem and thus it doesn't work.

I was wondering if anyone had any suggestions. Should I mount the harddrive inside the snap's writable area? Is it possible to give the snap access to the harddrive?

Best Answer

First of all, I should probably mention that this isn't really a support forum for the Nextcloud snap. If you have issues with it you can log a bug against it.

That said, someone already did, with the solution given here. It's now a wiki entry as well.

To quickly summarize here: you're right, this should be possible, and it is. However, by default the Nextcloud snap doesn't have permission to access removable media (as mentioned in its README).

So, the steps given are:

  1. Connect the removable-media plug: sudo snap connect nextcloud:removable-media.
  2. Connecting that interface gives Nextcloud permission to access things in /media/, so you can edit /var/snap/nextcloud/current/nextcloud/config/config.php and make sure the datadirectory is pointing to the right place.
  3. Disable the snap: sudo snap disable nextcloud
  4. Move (or copy) the current data directory to the new location: sudo mv /var/snap/nextcloud/common/nextcloud/data /media/my/new/data.
  5. Re-enable the snap: sudo snap enable nextcloud.

Now you don't need to bother with the external media solution: all of Nextcloud's data will be there.

Note that this only covers the raw data (e.g. files) hosted by Nextcloud. The database and apps are still in /var/snap/nextcloud/current/. I suggest you leave them there.