Nextcloud. Migrating the DATA directory

Once, to store nextcloud data, I created a raid and mounted it in a separate directory.

I looked in the configuration file for the path to the data directory (all user files are stored in it):

cat /var/www/nextcloud/config/config.php | grep datadirectory

It was displayed:

‘datadirectory’ => ‘/var/www/nextcloud/data’,

Then I turned on maintenance mode so that no one would take any action on the data:

sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --on

I copied the data directory to a new folder and indicated the owner and rights on behalf of which the web server is working:

cp -R /var/www/nextcloud/data /srv/nextcloud/data
chown -R www-data:www-data /srv/nextcloud/data/

I opened the nextcloud configuration file in a text editor and changed the “datadirectory” value to the path to the new folder:

nano /var/www/nextcloud/config/config.php

After that, I turned off the maintenance mode:

sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --off

Done, the “data” directory with user data has been successfully transferred to another location.

See also my articles:

Leave a comment

Leave a Reply