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

Once you move the data folder, you need to update the config.php file with the new datadirectory. For example,

‘datadirectory’ => ‘/private_html/datastorage’,

As far as I know this works fine with Nextcloud 10. I’m not sure about older versions.