Shares on external storage lost

Nextcloud version : 25.0.13
Operating system and version : Ubuntu 20.04.6 LTS
Apache or nginx version : 2.4.41-4ubuntu3.14
PHP version : 7.4.3

Hi everyone,

I created external SMB/CIFS shares using username/password authentication
The external storage is a windows 2016 serveur.
The connection is running fine , we have access to the files. We also created shares to publish some of these files to external users.
Everything was going greatfor a couple of years and suddenly, all these shares disappeared. Shares from internal storage are fine but all shares pointing to the external storage are now missing. They are also missing in the oc_shares mysql table.
So far, the only way we could manage to recover the shares (hundreds) is to restore a backup of the server.
It goes on for one week or two and the problem comes back.
When I test the external storage with smbclient, the resource is available. Therefore I assume the problem doesn’t come from the Windows Server.
The only thing I could notice from nextcloud.log, is this :

{"reqId":"KiBISwotm5kq29XAl43I","level":3,"time":"2023-11-24T17:30:45+01:00","remoteAddr":"","user":"--","app":"files","method":"","url":"/next/cron.php","message":"Unknown error (NT_STATUS_OBJECT_NAME_INVALID) for /","userAgent":"--","version":"","exception":{"Exception":"Icewind\\SMB\\Exception\\Exception","Message":"Unknown error (NT_STATUS_OBJECT_NAME_INVALID) for ...

It is like the external storage gets invalidated for some mysterious reasons.


$CONFIG = array (
  'force_language' => 'fr',
  'force_locale' => 'fr_FR',
  'passwordsalt' => '',
  'secret' => '',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => '',
    2 => '',
    3 => '',
  'trusted_proxies' =>
  array (
    0 => '',
    1 => '',
  'overwritewebroot' => '/next',
  'overwritehost' => '',
  'overwriteprotocol' => 'https',
  'overwritecondaddr' => '^192\\.168\\.1\\.1$',
  'datadirectory' => '/mnt/ncdata',
  'dbtype' => 'pgsql',
  'version' => '',
  'overwrite.cli.url' => '',
  'dbname' => 'nextcloud_db',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => '',
  'dbpassword' => '',
  'installed' => true,
  'instanceid' => 'ocbe8edq48vi',
  'upgrade.disable-web' => 'true',
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'loglevel' => 2,
  'log.condition' =>
  array (
    'apps' =>
    array (
      0 => 'admin_audit',
  'mail_smtpmode' => 'smtp',
  'remember_login_cookie_lifetime' => '1800',
  'log_rotate_size' => '10485760',
  'trashbin_retention_obligation' => 'auto, 180',
  'versions_retention_obligation' => 'auto, 365',
  'simpleSignUpLink.shown' => 'false',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'filelocking.enabled' => true,
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.5,
    'dbindex' => 0,
    'password' => '',
  'logtimezone' => 'Europe/Paris',
  'htaccess.RewriteBase' => '/',
  'maintenance' => false,
  'mail_from_address' => 'nextcloud',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => '',
  'mail_smtpport' => '465',
  'mail_smtphost' => '',
  'mail_smtpsecure' => 'ssl',
  'mail_smtpauth' => 1,
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpname' => '',
  'mail_smtppassword' => '',
  'enable_previews' => false,
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'default_phone_region' => 'FR',

We are having the same issue. Various nextcloud instances with smb external storage affected.
We regularly lose all Nextcloud shares to SMB External Storage folders or files. Our assumption is that this happens due to regular expected interruptions of the SMB server, due to Windows updates or other intentional interruptions, the SMB server is temporarily unavailable and the Nextcloud server then deletes all shares that are on this external storage. Although the SMB external storage is automatically reconnected, the shares are deleted. It would be great if this could be prevented. It is to be expected that external storage connection could be interrupted shortly because of normal maintenance work and this should not have such an effect.

We help ourselves by using the app Configurable Share Links - Apps - App Store - Nextcloud so we can recreate the deleted links but this is not really a solution…

Nextcloud version :
Operating system and version : Ubuntu 22.04.3 LTS
Apache version : 2.4.52-1ubuntu4.6
PHP version : 8.1.2

i have a similar frustration with nfs mounts that i use, if nextcloud is able to start up with the share not mounted it thinks the entire users directory is empty and wipes everything from the user. ive since made some changes to startup of the docker container to try and not start if the nfs shares are not there, but currently i ahve the whole data folder set up as a mount so if that isnt there then the nextcloud container says its missing a data file in the root of the folder and halts startup, its not the best workaround but it seems to work ok. im not sure how well it would handle brief interruptions though

1 Like

We are not using docker, nextcloud is installed natively on a Ubuntu VM and SMB server are independent Windows VMs. We could workaround this issue if we stop the whole VM or only apache service during our maintenance windows so that nextcloud can not detect that the SMB servers are down during maintenance. Not a nice workaround but would work.
I think this problem only occurs if the interruption lasts longer than a few minutes, short interruptions of a few seconds are not affected.

Thanks for your feedback, this is very interesting.
If we are suffering from the same issue (not sure yet), it is also super annoying. What is the point of having external storage if we cannot decouple/separate system and storage ?
This is a recent regression. With previous version of NC we didn’t have to bother with that.
We are not using the docker version either.

One difference between your setup and mine is that my mount is in /etc/fstab of my vm where i have the container, i then have the container with a bind mount of the location mapped to the data folder inside the container. it looks like you have the mnt specified as the data directory in the config.

since youre not using docker, have you tried having your data directory not modified in the nextcloud config, but mounting your data location in fstab at the location that is default for how you have nextcloud installed?

We are using the nextcloud external storage app for mounting smb shares, data directory is a standard local folder and via LDAP config we set a quota of 0B, like this users can only write into the mounted smb folders via external storage and not into the local data directory.
Since we have different setups with different ways of mounting external storage (fstab mount and nextcloud external storage app), I think this is just a basic mechanism of nextcloud to check the availability of every share periodically and delete it if it is unavailable for some time. I think it doesn’t matter what storage backend it has, I assume this just happens if a share target is unavailable. I could imagine that the reason for this is to track changes outside of nextcloud ( so if a folder with a share is deleted externally also the share is removed automatically), so kind of a way of housekeeping.

Perhaps, there are some modifications we can do to the cron.php script to disable that ?

I could try that but I fear this is going to reset all shares for good, and we have a lot of them…

yeah it would be a significant change on the server side, with not much hope of fixing what youre seeing.

Having the same issue. Any solutions to this?
It’s really annoying