Files deleted from SMB server gets reuploaded from sync-client

Nextcloud version (eg, 12.0.2): 13.0.6
Operating system and version (eg, Ubuntu 17.04): CentOS 7
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.6
PHP version (eg, 7.1): PHP 7.0.33

The issue you are facing:

Our users are connection to External Storage shares on a Windows 2016 fileserver. They use the Windows-client to sync shares to local PC.

They normally use a terminalserver to access these files (MS Office-files mainly), but some users need local access to the files, so they have the Windows Nextcloud client locally to have copies of the files locally.

Every now and then someone cleans up on the fileserver, and deletes old files. What happens is that after a while one of the users with local copy will upload the deleted files again.

It seems to happen only if the client is offline when the deletions happen on the server.

Is this the first time you’ve seen this error? (Y/N): Has happened at least 2 or 3 times. It is possible we have not noticed every time it has happened. But we have a few users that sync up to 60 GB.

Steps to replicate it:

  1. Does not happen every time, but has happened 2-3 times in the past.
  2. Connect windows client to a external storage smb share, and sync some files. Take client offline.
  3. Delete some files from server.
  4. Take client online. Deleted files will be reuploaded.

I have no log entries from when it happened. I will try to catch this the next time.

Hello, and welcome back to the Nextcloud forums!

So the problem is that since the change wasn’t made through Nextcloud, the database hasn’t been updated to show the file was deleted. When the client reconnects, Nextcloud compares the client’s version of the file against the non-existent file that the database still believes should be there. The client’s version ‘wins’, and the SMB share is updated to ‘fix’ its deleted file.

If you can’t make all future changes through Nextcloud so that it keeps its database up to date (not always feasible, I know), you can schedule Nextcloud to double-check the SMB share with a cron job. Nextcould’s docs for SMB shares come in handy with a shortcut, so that we don’t have to scan every single file again:

  1. Find the mount ID of the SMB share:
    occ files_external:list
  2. Launch a separate process that watches for changed files on that share:
    occ files_external:notify <mount_id>
    You may want to add this as a separate service to be run on boot, but that’s beyond this answer for now.
  3. Whenever a file is changed, Nextcloud’s database will be updated next time its cron job is run. If you want to make it more often than your other Nextcloud cron tasks, you can do like I did, and add this to the www-data user’s crontab:
    */15 * * * * php /var/www/nextcloud/occ files:scan --unscanned --all

I’d be glad to hear back if this solves your problem, or if you run into any further questions!

Thanks for replying!

Ok, that makes sense.

We use LDAP and “Log in credentails, save in database”. It seems that is not compatible with notify? I get:

Error while trying to create storage
Username and/or password required

when trying. I will try number 3.

Thanks!

Hi again, a follow-up question for this,

I use “Log in credentials, save in database”. The doc says that “the notify process can not use the credentials saved to attach to the smb shares because the notify process does not run in the context of a specific user in those cases you can provide the username and password”

I do not have the username and password of these users, but can I use an administrator account for the notify instead?

Hello, there is no answer, but a question with the same (?) Topic:

Ordner/Dateien lassen sich nicht löschen - - Edit shared folders - folders / files can not be deleted

Hallo Alle …
ich habe folgende Konstruktion:

Ubuntu Server - aktuell
Nextcloud Vers. 15 - aktuell
mehrere Mac Rechner - verbunden über den Desktop Clienten
einige gemeinsam genutzte Ordner auf dem Server
Das Problem ist:
Ein User will einen vorhandenen Ordner oder Datei löschen,
das scheint zu funktionieren,
nach einiger Zeit (Intervall noch nicht eindeutig) ist der gelöschte Ordner/Datei wieder am Ursprungsplatz,
Das Gleiche passiert auch beim Löschen über das Webfenster,
(WebDAV habe ich noch nicht getestet)
Warum ist das so und wie kann ich das ändern?

Freundliche Grüsse in die Runde …
Frank

Das gleiche nochmal, nur mit Google übersetzt … The same again, just translated to Google …

Hello everyone …
I have the following construction:

Ubuntu server - up to date
Nextcloud verse 15 - current
Several Mac computers - connected via the desktop client
some shared folders on the server
The problem is:
A user wants to delete an existing folder or file
that seems to work
after some time (interval not yet clear) the deleted folder / file is back at the place of origin,
The same thing happens when deleting via the web window,
(I have not tested WebDAV yet)
Why is that and how can I change that?

Best regards in the round …
Frank

@Roald The answer to that is ‘yes’, but just to be clear: the credentials that it needs are for the SMB side, not the Nextcloud side, if I’m reading that correctly. So long as the username/password you provide is for an account that has read-permission for all files in the SMB share, this should work as expected.

@frankw If I’m reading this correctly, you have tried deleting files from Mac computers running the Nextcloud sync client, and also from the Nextcloud web interface, and these files re-appear afterwards. I have some questions for you:

  • Where is the ‘place of origin’ - is it an external share that Nextcloud accesses, or is it directly in Nextcloud?
  • Do you have any other kind of sync software running on any of the clients?
  • When a user deletes a file from a shared folder, does that show up in the ‘Activities’ app for any other user that has access to that share?

Hello Roald,

    many thanks for the answer.

              The files / folders are directly in the

Nextcloud.

              No software other than Nextcloud Client

is used.

              And the deletion process is displayed

correctly in the activity.

              (Whether carried out via local folder or

web window)

    There is no data release via SMB.

freundliche Grüsse

Frank W

Thanks @mactrent!

hello roald,

      Unfortunately, I have just received your mail (20.05.).

      So unfortunately I can only answer to it now. Sorry ...

      To clarify:

      - Apart from the nextcloud client, I have no other sync

software installed or in use

      - The release is set up and released as admin.

      the problem is:

      I create a

folder or file in the local nextcloud-client directory. this
is shared with the other authorized users via the nextcloud
server. If I delete this folder / file again, the deleted
object is restored after 30 to 60 minutes and is available
again at the previous location.

      I have tried it with different operating systems (mac x.11,

x.12 x.13 and x.14, windows 7 and 10, linux debian and ubuntu
desktop), different file types, new folders and existing
folders, different, sometimes too newly created users, access
via webdav or web window - the result was always the same.

      Add files and folders is always - remove, even moving to other

existing folders, does not work.

      maybe you have an idea?

      friendly greetings from Stuttgart

      frank

      PS: translated

with translate.google.com


Hallo Nextcloud Forum.

nach etwas Suche, habe ich Lösung für dieses Problem gefunden.

Eigentlich sehr einfach …

Ich war selbst schuld dran.

  Zum Backup habe ich auf einen Client Rechner ein Backup Programm

eingerichtet.

  Das hat nicht von Datenquelle zum lokalen Backupordner kopiert -

Nein, es hat diese beiden Ordner sychronisiert.

  Alles was vom Cloud Server entfernt wurde, wurde nach knapp 1

Stunde vom Backup wiederhergestellt.

  Jetzt habe ich das Backup Programm richtig eingestellt >

Problem ist weg.

(Es war nur ein winzig kleines Kreutzchen zum setzten …)

Freundliche Grüsse

Frank Wiedemann