Nextcloud version : 18.0.3.0
Operating system and version : Debian 10 (NextcloudPi)
Apache version: 2.4.38
PHP version : PHP 7.3.14
The issue you are facing:
I changed my data directory according to this tutorial: HowTo: Change / Move data directory after installation . I adjusted the following pathes of data_directory, tempdirectory and logfile to pathes on my new drive at /media/Nextcloud-Data, as written in my config.php:
Summary
$CONFIG = array (
'passwordsalt' => *removed*,
'secret' =>*removed*,
'trusted_domains' =>
array (
0 => 'localhost',
5 => 'nextcloudpi.local',
7 => 'nextcloudpi',
8 => 'nextcloudpi.lan',
11 =>*removed*,
1 => '192.168.2.103',
3 => *removed*,
4 => *removed*,
),
'datadirectory' => '/media/Nextcloud-Data/NC-Data',
'dbtype' => 'mysql',
'version' => '18.0.3.0',
'overwrite.cli.url' => *removed*,
'dbname' => 'nextcloud',
'dbhost' => 'localhost',
'dbport' => '',
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
'dbuser' => 'ncadmin',
'dbpassword' => *removed*,
'installed' => true,
'instanceid' => 'oc8iggjkub4w',
'memcache.local' => '\\OC\\Memcache\\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' =>
array (
'host' => '/var/run/redis/redis.sock',
'port' => 0,
'timeout' => 0.0,
'password' => *removed*,
),
'tempdirectory' => '/media/Nextcloud-Data/nc-tmp',
'mail_smtpmode' => 'sendmail',
'mail_smtpauthtype' => 'LOGIN',
'mail_from_address' => 'admin',
'mail_domain' => 'ownyourbits.com',
'preview_max_x' => '2048',
'preview_max_y' => '2048',
'jpeg_quality' => '60',
'overwriteprotocol' => 'https',
'maintenance' => true,
'logfile' => '/media/Nextcloud-Data/nc-log/nextcloud.log',
'loglevel' => 2,
);```
I also created the needed directories on /media/Nextcloud-Data and gave ownership to user www-data:
drwxr-xr-x 1 www-data www-data 584 May 1 10:32 NC-Data
drwxr-xr-x 1 www-data www-data 0 May 5 16:06 nc-log
drwxr-xr-x 1 www-data www-data 0 May 5 16:05 nc-tmp
Now i recognized two problems:
First, I wanted to remove the new pathes in my database using the commands from the tutorial:
dbuser=$(awk -F\' "/'dbuser'/{print \$4;exit}" /path/to/nextcloud/config/config.php)
dbpassword=$(awk -F\' "/'dbpassword'/{print \$4;exit}" /var/www/nextcloud/config/config.php)
mysql -u$dbuser -p$dbpassword
// Inside the MySQL console:
use <nextclouddb>;
update oc_storages set id='local::/new/path/to/data/' where id='local::/path/to/data/'; //take care about backslash at the end of path!!
quit;
// Again outside the MySQL console
unset dbuser dbpassword
After the update command, I received the message:
ERROR 1062 (23000): Duplicate entry 'local::/media/Nextcloud-Data/NC-Data/' for key 'storages_id_index'
I ignored this for first. Because I copied my files manually to the new directory /media/Nextcloud-Data/NC-Data, i had to run nc-scan. But here comes the following message:
Nextcloud is in maintenance mode - no apps have been loaded
Your data directory is invalid
Ensure there is a file called ".ocdata" in the root of the data directory.
Cannot create "data" directory
This can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/18/go.php?to=admin-dir_permissions
An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:167
Stack trace:
#0 /var/www/nextcloud/console.php(98): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')
I am also not able to open the Web-API.
How can I solve this problem? Is the MariaDB error relevant in this case? And do I even have to run the database update, when I have to rescan all my files anyway? Thanks in Advance!