nextcloud snap with data-directory on external harddrive
A bug was logged against the Nextloud snap for this issue, 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:
- Connect the
removable-media
plug:sudo snap connect nextcloud:removable-media
. - 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 thedatadirectory
is pointing to the right place. - Disable the snap:
sudo snap disable nextcloud
- Move (or copy) the current data directory to the new location:
sudo mv /var/snap/nextcloud/common/nextcloud/data /media/my/new/data
. - 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.
Note: if you have issues with the Nextcloud snap, you can log a bug against it.
Use 'stop' instead of 'disable' otherwise you won't be able to edit config.php.
Enable external storage for snap: sudo snap connect nextcloud:removable-media
Stop nexcloud snap: sudo snap stop nextcloud
Update storage location: sudo vim /var/snap/nextcloud/current/nextcloud/config/config.php
change data location:
'datadirectory' => '/media/storage/data',
Move the data directory to the storage device: sudo mv /var/snap/nextcloud/common/nextcloud/data /media/storage/
Start nextcloud snap: sudo snap start nextcloud