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

**URL:** <https://help.nextcloud.com/t/is-there-a-safe-and-reliable-way-to-move-data-directory-out-of-web-root/3642>\
**Category:** ℹ️ Support\
**Created:** [September 27, 2016, 7:30pm UTC](https://help.nextcloud.com/t/is-there-a-safe-and-reliable-way-to-move-data-directory-out-of-web-root/3642 "2016-09-27T19:30:52Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![robertb](https://help.nextcloud.com/letter_avatar/robertb/32/5_5575768a8748004e209b776fc1b2916d.png) [@robertb](https://help.nextcloud.com/u/robertb)\
**Post date:** [September 30, 2016, 2:15am UTC](https://help.nextcloud.com/t/is-there-a-safe-and-reliable-way-to-move-data-directory-out-of-web-root/3642/17 "2016-09-30T02:15:16Z")

</div>

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](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.

---

_[View the full topic](https://help.nextcloud.com/t/is-there-a-safe-and-reliable-way-to-move-data-directory-out-of-web-root/3642)._
