Is there a safe and reliable way to move data directory out of web root?

Success!

So with a little digging, I learned that I could convert my database from sqlite3 to MySQL using the following:

https://docs.nextcloud.com/server/10/admin_manual/configuration_database/db_conversion.html

At that point my Nextcloud database was accessible through phpmyadmin. Then I followed grouchysysadmin’s steps above:

0: Back everything up first.
1: Disable access to Nextcloud. (maintenance mode)
2: Move the data folder.
3: Edit the database table oc_storage. Change the local::/path/to/data to local::/new/path/to/data.
4: Edit the config.php datadirectory line to reflect the new path.
5: Turn off maintenance mode.

In my case, I move the data directory to /etc/nextclouddata/nextcoud/data. When trying to load my login page for the first time, I got the following error:

Data directory (/etc/nextclouddata/nextcloud/data/) is invalid. Please check that the data directory contains a file “.ocdata” in its root.

Running…

chown -R www-data:www-data /etc/nextclouddata/nextcoud/data

…fixed that error and everything looks to be running perfectly again.

Many thanks to @grouchysysadmin and @nickvergessen for helping me through this.

2 Likes