I've installed the NextCloud snap on my Ubuntu 18.04 Server.
After successful installation, I created a user through the command line and then I changed the data directory to a new media drive that is linked with a symbolic soft link to the directory /cloud-data.
In particular, I've gone through the following steps:
I've connected the removable media plug:
sudo snap connect nextcloud:removable-media
Disable the snap:
sudo snap disable nextcloud
I've changed the
datadirectory
in/var/snap/nextcloud/current/nextcloud/config/config.php
and the new config is:$CONFIG = array ( 'apps_paths' => array ( 0 => array ( 'path' => '/snap/nextcloud/current/htdocs/apps', 'url' => '/apps', 'writable' => false, ), 1 => array ( 'path' => '/var/snap/nextcloud/current/nextcloud/extra-apps', 'url' => '/extra-apps', 'writable' => true, ), ), 'supportedDatabases' => array ( 0 => 'mysql', ), 'memcache.locking' => '\\OC\\Memcache\\Redis', 'memcache.local' => '\\OC\\Memcache\\Redis', 'redis' => array ( 'host' => '/tmp/sockets/redis.sock', 'port' => 0, ), 'passwordsalt' => '<<char-sequence>>', 'secret' => '<<char-sequence>>', 'trusted_domains' => array ( 0 => 'localhost', 1 => '192.168.1.30', ), // 'datadirectory' => '/var/snap/nextcloud/common/nextcloud/data', 'datadirectory' => '/cloud-data/data', 'overwrite.cli.url' => 'http://localhost', 'dbtype' => 'mysql', 'version' => '13.0.7.2', 'dbname' => 'nextcloud', 'dbhost' => 'localhost:/tmp/sockets/mysql.sock', 'dbport' => '', 'dbtableprefix' => 'oc_', 'mysql.utf8mb4' => true, 'dbuser' => 'nextcloud', 'dbpassword' => '<<char-sequence>>', 'installed' => true, 'instanceid' => 'oczhujw1qh25', );
Moved the data directory into the new one:
sudo mv /var/snap/nextcloud/common/nextcloud/data /cloud-data
Enabled the snap:
sudo snap enable nextcloud.
Then, if I browse to 192.168.1.30
, I get an error page:
The server encountered an internal error and was unable to complete your request.
Looking at the log, I've found the following error:
{"reqId":"JQPdFyDWw7il9i9imtwS","level":3,"time":"2018-11-03T21:50:29+00:00","remoteAddr":"192.168.1.81","user":"myadminuser","app":"index","method":"GET","url":"\/index.php\/settings\/apps\/categories","message":"Exception:
{\"Exception\":\"Doctrine\\\\DBAL\\\\Exception\\\\
UniqueConstraintViolationException\",\"Message\":\"An exception occurred while executing 'INSERT INTO `oc_filecache`
(`mimepart`,`mimetype`,`mtime`,`size`,`etag`,`storage_mtime`,`permissions`,`parent`,`checksum`,`path_hash`,`path`,`name`,`storage`) SELECT ?,?,?,?,?,?,?,?,?,?,?,?,? FROM `oc_filecache` WHERE `storage` = ? AND `path_hash` = ? HAVING COUNT(*) = 0' with params [\\\"3\\\", \\\"19\\\", 1541281829, 0, \\\"8b012c172b627b19e3868612eda23a78\\\", 1541281829, 27, 137, \\\"\\\", \\\"c1139e3e0630754d022ce4372e608e19\\\", \\\"appdata_oczhujw1qh25\\\\\\\/appstore\\\\\\\/apps.json\\\", \\\"apps.json\\\", 2, 2, \\\"c1139e3e0630754d022ce4372e608e19\\\"]:\\n\\n
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2-c1139e3e0630754d022ce4372e608e19' for key 'fs_storage_path_hash'\",\"Code\":0,\"Trace\":\"#0 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/
DBALException.php(128): Doctrine\\\\DBAL\\\\Driver\\\\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException))\\n#1 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Connection.php(1015): Doctrine\\\\DBAL\\\\
DBALException::driverExceptionDuringQuery(Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOMySql\\\\Driver), Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException), 'INSERT INTO `oc...', Array)\\n#2 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/DB\\\/Connection.php(216):
Doctrine\\\\DBAL\\\\Connection->executeUpdate('INSERT INTO `oc...', Array, Array)\\n#3 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/DB\\\/Adapter.php(114): OC\\\\DB\\\\Connection->executeUpdate('INSERT INTO `oc...', Array)\\n#4 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/DB\\\/Connection.php(254): OC\\\\DB\\\\Adapter->insertIfNotExist('*PREFIX*filecac...', Array, Array)\\n#5 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Files\\\/Cache\\\/Cache.php(273): OC\\\\DB\\\\Connection->insertIfNotExist('*PREFIX*filecac...', Array, Array)\\n#6 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Files\\\/Cache\\\/Cache.php(230): OC\\\\Files\\\\Cache\\\\Cache->insert('appdata_oczhujw...', Array)\\n#7 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Files\\\/Cache\\\/Scanner.php(292): OC\\\\Files\\\\Cache\\\\Cache->put('appdata_oczhujw...', Array)\\n#8 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Files\\\/Cache\\\/Scanner.php(221): OC\\\\Files\\\\Cache\\\\Scanner->addToCache('appdata_oczhujw...', Array, -1)\\n#9 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Files\\\/Cache\\\/Scanner.php(336): OC\\\\Files\\\\Cache\\\\Scanner->scanFile('appdata_oczhujw...', 3, 137, false, true)\\n#10 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Files\\\/View.php(1326): OC\\\\Files\\\\Cache\\\\Scanner->scan('appdata_oczhujw...', false)\\n#11 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Files\\\/View.php(1369): OC\\\\Files\\\\View->getCacheEntry(Object(OCA\\\\Files_Trashbin\\\\Storage), 'appdata_oczhujw...', '\\\/appdata_oczhuj...')\\n#12 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Files\\\/Node\\\/Root.php(198): OC\\\\Files\\\\View->getFileInfo('\\\/appdata_oczhuj...')\\n#13 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Files\\\/Node\\\/Folder.php(133): OC\\\\Files\\\\Node\\\\Root->get('\\\/appdata_oczhuj...')\\n#14 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Files\\\/SimpleFS\\\/SimpleFolder.php(73): OC\\\\Files\\\\Node\\\\Folder->get('apps.json')\\n#15 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/App\\\/AppStore\\\/Fetcher\\\/Fetcher.php(145): OC\\\\Files\\\\SimpleFS\\\\SimpleFolder->getFile('apps.json')\\n#16 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Installer.php(401): OC\\\\App\\\\AppStore\\\\Fetcher\\\\Fetcher->get()\\n#17 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/settings\\\/Controller\\\/AppSettingsController.php(292): OC\\\\Installer->isUpdateAvailable('activity')\\n#18 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/settings\\\/Controller\\\/AppSettingsController.php(144): OC\\\\Settings\\\\Controller\\\\AppSettingsController->getAppsWithUpdates()\\n#19 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/settings\\\/Controller\\\/AppSettingsController.php(170): OC\\\\Settings\\\\Controller\\\\AppSettingsController->getAllCategories()\\n#20 [internal function]: OC\\\\Settings\\\\Controller\\\\AppSettingsController->listCategories()\\n#21 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/AppFramework\\\/Http\\\/Dispatcher.php(161): call_user_func_array(Array, Array)\\n#22 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/AppFramework\\\/Http\\\/Dispatcher.php(91): OC\\\\AppFramework\\\\Http\\\\Dispatcher->executeController(Object(OC\\\\Settings\\\\Controller\\\\AppSettingsController), 'listCategories')\\n#23 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/AppFramework\\\/App.php(115): OC\\\\AppFramework\\\\Http\\\\Dispatcher->dispatch(Object(OC\\\\Settings\\\\Controller\\\\AppSettingsController), 'listCategories')\\n#24 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/AppFramework\\\/Routing\\\/RouteActionHandler.php(47): OC\\\\AppFramework\\\\App::main('OC\\\\\\\\Settings\\\\\\\\Con...', 'listCategories', Object(OC\\\\AppFramework\\\\DependencyInjection\\\\DIContainer), Array)\\n#25 [internal function]: OC\\\\AppFramework\\\\Routing\\\\RouteActionHandler->__invoke(Array)\\n#26 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/private\\\/Route\\\/Router.php(297): call_user_func(Object(OC\\\\AppFramework\\\\Routing\\\\RouteActionHandler), Array)\\n#27 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/lib\\\/base.php(999): OC\\\\Route\\\\Router->match('\\\/settings\\\/apps\\\/...')\\n#28 \\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/index.php(42): OC::handleRequest()\\n#29 {main}\",\"File\":\"\\\/snap\\\/nextcloud\\\/9551\\\/htdocs\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Driver\\\/AbstractMySQLDriver.php\",\"Line\":66}","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.77 Safari\/537.36","version":"13.0.7.2"}
I've tried to truncate the table oc_filecache
, hoping that after the regeneration everything went fine, but nothing has changed.
I have followed the instructions on the official website, but I think that something is missing. Maybe I need to change something in the database? Or maybe a chown
to a particular user?
Found the issue:
I can't specify the data directory using the soft link in the config file.
After inserting the real path (
/media/sdb/data
) everything went fine