Moving large Nextcloud installation to another server loses information

Nextcloud version : 19.0.4
Operating system and version (eg, Ubuntu 20.04): Debian buster
Apache or nginx version (eg, Apache 2.4.25): nginx/1.14.2
PHP version (eg, 7.4): 7.3.27-1

The issue you are facing:
I want to move my large Nextcloud installation to a new, faster server. But, when I do, some of the sharing information gets lost.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Copy the contents of /var/www/nextcloud, /data/ncdata (the data folder) to the new server
  2. Dump the database on the old server and reload on the new one
  3. Look at a folder which is shared to a group you are in

The folder appears, but opening it shows no files, and looking at the sharing tab for the folder says (eventually) “Unable to load the shares list”.

The output of your Nextcloud log in Admin > Logging:

OCP\Files\StorageNotAvailableException: File with id "23432" has not been found.
/data/nextcloud/html/apps/files_sharing/lib/SharedStorage.php - line 428:

OC\Files\Storage\FailedStorage->acquireLock("", 1, OC\Lock\Memc ... {})

/data/nextcloud/html/lib/private/Files/Storage/Wrapper/Wrapper.php - line 590:

OCA\Files_Sharing\SharedStorage->acquireLock("", 1, OC\Lock\Memc ... {})

/data/nextcloud/html/lib/private/Files/View.php - line 1968:

OC\Files\Storage\Wrapper\Wrapper->acquireLock("", 1, OC\Lock\Memc ... {})

/data/nextcloud/html/lib/private/Files/View.php - line 2083:

OC\Files\View->lockPath("/ddat/files ... s", 1, false)

/data/nextcloud/html/lib/private/Files/Node/Node.php - line 381:

OC\Files\View->lockFile("/ddat/files ... s", 1)

/data/nextcloud/html/apps/files_sharing/lib/Controller/ShareAPIController.php - line 1497:

OC\Files\Node\Node->lock(1)

/data/nextcloud/html/apps/files_sharing/lib/Controller/ShareAPIController.php - line 758:

OCA\Files_Sharing\Controller\ShareAPIController->lock(OC\Files\Node\Folder {})

/data/nextcloud/html/lib/private/AppFramework/Http/Dispatcher.php - line 169:

OCA\Files_Sharing\Controller\ShareAPIController->getShares("false", "true", "false", "/Communications Tools", "false")

/data/nextcloud/html/lib/private/AppFramework/Http/Dispatcher.php - line 100:

OC\AppFramework\Http\Dispatcher->executeController(OCA\Files_Sh ... {}, "getShares")

/data/nextcloud/html/lib/private/AppFramework/App.php - line 152:

OC\AppFramework\Http\Dispatcher->dispatch(OCA\Files_Sh ... {}, "getShares")

/data/nextcloud/html/lib/private/Route/Router.php - line 309:

OC\AppFramework\App::main("OCA\\Files_ ... r", "getShares", OC\AppFramew ... {}, { _route: "o ... "})

/data/nextcloud/html/ocs/v1.php - line 88:

OC\Route\Router->match("/ocsapp/app ... s")

/data/nextcloud/html/ocs/v2.php - line 24:

require_once("/data/nextc ... p")

Caused by OCP\Files\NotFoundException: File with id "23432" has not been found.
/data/nextcloud/html/apps/files_sharing/lib/SharedStorage.php - line 130:

OC\Files\View->getPath(23432, 8)

/data/nextcloud/html/apps/files_sharing/lib/SharedStorage.php - line 487:

OCA\Files_Sharing\SharedStorage->init()

/data/nextcloud/html/lib/private/Files/Storage/Wrapper/Wrapper.php - line 496:

OCA\Files_Sharing\SharedStorage->getWrapperStorage()

/data/nextcloud/html/apps/files_sharing/lib/SharedStorage.php - line 168:

OC\Files\Storage\Wrapper\Wrapper->instanceOfStorage("OCP\\Files\\IHomeStorage")

/data/nextcloud/html/apps/groupquota/lib/AppInfo/Application.php - line 58:

OCA\Files_Sharing\SharedStorage->instanceOfStorage("OCP\\Files\\IHomeStorage")

/data/nextcloud/html/lib/private/Files/Storage/StorageFactory.php - line 101:

OCA\GroupQuota\AppInfo\Application->OCA\GroupQuota\AppInfo\{closure}("*** sensiti ... *")

/data/nextcloud/html/lib/private/Files/Mount/MountPoint.php - line 150:

OC\Files\Storage\StorageFactory->wrap("*** sensiti ... *", "*** sensiti ... *")

/data/nextcloud/html/lib/private/Files/Mount/MountPoint.php - line 174:

OC\Files\Mount\MountPoint->createStorage()

/data/nextcloud/html/lib/private/Files/View.php - line 1412:

OC\Files\Mount\MountPoint->getStorage()

<<closure>>

OC\Files\View->OC\Files\{closure}("*** sensiti ... *")

/data/nextcloud/html/lib/private/Files/View.php - line 1414:

array_filter([ OCA\GroupF ... "], Closure {})

/data/nextcloud/html/lib/private/Files/Node/Root.php - line 201:

OC\Files\View->getFileInfo("/ddat/files")

/data/nextcloud/html/lib/private/Files/Node/Root.php - line 382:

OC\Files\Node\Root->get("/ddat/files")

<<closure>>

OC\Files\Node\Root->getUserFolder("ddat")

/data/nextcloud/html/lib/private/Files/Node/LazyFolder.php - line 66:

call_user_func_array([ OC\Files\N ... "], [ "ddat"])

/data/nextcloud/html/lib/private/Files/Node/LazyRoot.php - line 41:

OC\Files\Node\LazyFolder->__call("getUserFolder", [ "ddat"])

/data/nextcloud/html/apps/files_sharing/lib/Controller/ShareAPIController.php - line 755:

OC\Files\Node\LazyRoot->getUserFolder("ddat")

/data/nextcloud/html/lib/private/AppFramework/Http/Dispatcher.php - line 169:

OCA\Files_Sharing\Controller\ShareAPIController->getShares("false", "true", "false", "/Communications Tools", "false")

/data/nextcloud/html/lib/private/AppFramework/Http/Dispatcher.php - line 100:

OC\AppFramework\Http\Dispatcher->executeController(OCA\Files_Sh ... {}, "getShares")

/data/nextcloud/html/lib/private/AppFramework/App.php - line 152:

OC\AppFramework\Http\Dispatcher->dispatch(OCA\Files_Sh ... {}, "getShares")

/data/nextcloud/html/lib/private/Route/Router.php - line 309:

OC\AppFramework\App::main("OCA\\Files_ ... r", "getShares", OC\AppFramew ... {}, { _route: "o ... "})

/data/nextcloud/html/ocs/v1.php - line 88:

OC\Route\Router->match("/ocsapp/app ... s")

/data/nextcloud/html/ocs/v2.php - line 24:

require_once("/data/nextc ... p")```

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'passwordsalt' => 'removed',
  'secret' => 'removed',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => 'removed',
  ),
  'datadirectory' => '/data/nextcloud/ncdata',
  'dbtype' => 'mysql',
  'version' => '19.0.4.2',
  'overwrite.cli.url' => 'http://localhost',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextcloud',
  'dbpassword' => 'removed',
  'installed' => true,
  'instanceid' => 'removed',
  'activity_expire_days' => 1,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'localhost',
    'port' => 6379,
    'timeout' => 1.5,
    'password' => '',
  ),
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'mail_from_address' => 'ddat+cloud',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'removed',
  'mail_smtphost' => '127.0.0.1',
  'mail_smtpport' => '25',
  'maintenance' => false,
  'default_locale' => 'en-GB',
  'default_language' => 'en-GB',
  'loglevel' => 2,
  'updater.release.channel' => 'stable',
  'theme' => '',
);

The output of your Apache/nginx/system log in /var/log/____:
Don’t have a system log, only access and error logs. They don’t show anything except the page loading.

Is there an occ command I need to run to sort this out?

I think I have got to the bottom of this.

On the new server, the Nextcloud data directory was at a different path. So Nextcloud created a new entry in oc_storages for the new path, and everything in the old storage stopped working.

I added a symbolic link so the area could be reached using the old path, but that didn’t help.

I have just re-transferred everything across, and edited the oc_storages table in the database to change the path to the new one.

That seems to have helped.

But be warned - don’t move your data directory!