Change default Data directory on Nextcloud

quickbox-pro

#1

By default, Nextcloud data folder is located in the /srv/nextcloud/data folder.
For example, after installation I had only 6Gb available. It depends of your system and the amount of storage you have.

In this little wiki, I’ll show you how to move your data to a bigger location. Be careful, do this only when you are not transferring files.

First of all, you need to edit the /srv/nextcloud/config/config.php file.

<?php
$CONFIG = array (
  'instanceid' => 'xxxx',
  'passwordsalt' => 'xxxx',
  'secret' => 'xxxx',
  'trusted_domains' =>
  array (
    0 => 'YOUR_DOMAIN_HERE',
  ),
  'datadirectory' => '/srv/nextcloud/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '15.0.7.0',
  'overwrite.cli.url' => 'https://YOUR_DOMAIN.COM/nextcloud',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost:443',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'YOUR_USER',
  'dbpassword' => 'YOUR_PASSWORD',
  'installed' => true,
);

The is an example of the config file. You only need to edit the line 'datadirectory' =&gt; '/srv/nextcloud/data' and change it to an other location.
If you change it to 'datadirectory' =&gt; '/home/YOUR_USER/nextcloud/data' , you’ll be able to set tup quotas (with the additional package on your dashboard) or use the built-in quota system in Nextcloud.

After that, you’ll see that you can’t connect to nextcloud, so you need to do the following :

mkdir /home/YOUR_USER/nextcloud/
cp -R /srv/nextcloud/data /home/YOUR_USER/nextcloud/
chown -R www-data: /home/YOUR_USER/nextcloud/
service nginx reload && php7.2-fpm reload

Go back to your Nextcloud, and Voilà ! :slight_smile: