Sync on SMB: Server is overwriting clients files

I am having issues with SMB syncing on Windows clients (Only client I have tested).

I have having multiple problems but hopefully it is all the same cause, I just need to figure out what the cause is.
First major problem is I can create new files on the clients and Nextcloud will sync them but if I modify the files from the clients 2/3 of the time I will get a sync conflict and the server version of the file will override the client files even when the client files are a newer version.

Second Problem is sometimes I get a file that is synced constantly without any modifications to the file anywhere. It just downloads from the server every 2-10 minutes, notifying me every time.

And last but not least I also get a message every once in awhile saying the files on the server have been restored from an earlier time and it asks if I want to keep client files or sync the server files. This usually happens when I am modifying a file on the client side.

To keep things simple on my tests I am not modifying any files from the SMB server directly, all file modifications are going though Nextcloud.

The only person with a similar issue I have found is this thread

I have changed all of the NTP server to be the same on all clients. Still not positive it it actually took affect on my Nextcloud server, but looking at the time between all of the servers they are very close it is hard to tell exactly but I would say at least within a second.

I have also run the OCC file scan on the Nextcloud server multiple times.

My setup.
Nextcloud Server
Nextcloud 11.0.0 Stable
PHP Version 7.0.8
mysql Version 5.7.16
OS Linux Mint 18 (Updated)

SMB Server
FreeNAS 9.10
Local connection

2 Windows 7 Clients (Remote)
2 Windows 10 (Local)

Currently I am the only user.

The Server has about 35,000 files of that only 3,500 files are synced. (Most files are static files).

This is only a problem with files over the SMB I tried a few times with files directly on the Nextcloud and I couldn’t duplicate the problem.

Any ideas?

Could you check the current time across all your devices. Also have you try to rescan all files?

From what I can tell the time is correct across all devices. The SMB Server and Nextcloud server are on the same NTP server.

The clients are also on a NTP server but a different one.

Eye balling the time across all servers they are all within at least 2 second if not 1 second. the SMB server doesn’t have a GUI so I have to run date from the terminal, and I can’t run it at the exact time. So it is hard to tell.

I have also run a re scan multiple times with out success.

I double and tripled checked my time settings, used different NTP servers, and even setup my Nextcloud server as a NTP server and setup my FreeNAS SMB server to grab time from that. No luck at all still very much broken.

I also scanned all the files multiple times, and tried to sync things after the scan completed, no luck.

So I gave up, removed the SMB share from the external storage. I mounted the SMB share to a local folder on my Nextcloud server and pointed Nextcloud at that folder using the local option under external storage.

I ran a another file scan to make sure Nextcloud is all up to speed on the files. Now all of my clients are working perfectly. I tried multiple times to brake it but haven’t been able too.

I added the SMB mount to fstab and hopefully that should be it. Now on to the true test and see if it behaves in real world situations.

I am still at a loss as to why it wasn’t working with the built in Nextcloud SMB external storage. Maybe I setup something wrong, or there is a compatibility bug in my setup somewhere, Nextcloud FreeNAS, Linux Mint etc… If I get ambitious I might try and setup a SMB share with windows or something and see if I can duplicate the same problems.

But I thought I would share my fix if anyone else is in the same situation.

I have a very similar setup, and ran into exactly the same problem. I wonder if the user of the SMB server that is logged in might be using a different timezone, or something. I’ll check the timestamps of the files themselves to see if they look accurate.
Maybe the potential of the timestamps between the nextcloud server, and NAS server clocks might be asking for trouble?

Modified timestamps show about a second apart between versions, or so Windows explorer was reporting. Probably need to look at the number in the file to really be sure. I don’t know why the file modification time would be updated, but if it is; maybe that has something to do with it.

My nextcloud server itself actually has a very good hardware clock. I think I’ll sync that server to, then use it’s time server to sync all the other servers on my network to. I setup that server to broadcast the time as well. We’ll see if it behaves better after that.

A little early in the testing, but so far, the behavior is much better. Most of the issues appear to be gone. They don’t seem to be completely gone, but I’m not sure what is caused by which issue at the moment, need more testing.

I wonder if mounting the NAS servers to the Nextcloud server using NFS would have any positive affect on this behavior. I know it will have better I/O performance after I setup all the permissions correctly, but I wonder if it would affect this timestamp sync issue. So far I have very positive results simply by syncing the time of my servers together. It will be four days before I can do much testing again, though. I’ll need to use it for a while to understand performance issues. If anybody has any experience here, please chime in.

I had the same problem as you (forum link). Using the built-in external storage support caused all sorts of problems. In the end, I’ve setup normal samba shares inside nextcloud/data/[username]/[foldername]. Has been running like this for about a month without problems.

Yeah you did the same thing I did. No problems yet over here either.


  • Do you mean you used the OS smb or cifs client to mount external NAS drives to user folders?

  • If so, did you create a separate mount for each user’s directory?

  • Also, did you think it might be a bug in php5-smbclient?

I haven’t had time to fully test my server time sync solution. I don’t know if it completely eliminated the problem, but it definitely improved performance. I now have a different unrelated minor problem causing sync issues that I haven’t been able to dig into; and I think I just want to switch to a Raspberry Pi 3 due to high levels of support. It is taking me a while to do that.

Just be aware this isn’t supported and may lead to issues. NC isn’t necessarily designed to pick up changes on the underlying filesystem (unless external storage is used) and may result in confusion with the database.


  • yes
  • no. just mounted folders inside users’ folders
  • I have no idea. I’ve tried with php5-smbclient and simple smbclient with the same result.


I’ve setup a cron job to scan for all files every half an hour. The contents of the samba share is modified almost exclusively through nextcloud sync.

That’s fine, just so you know :slight_smile:


Thanks! I’m using a 3-2-1 backup strategy so my only concern is silent long-term data corruption but I suspect NC doesn’t do that.

1 Like

Along those lines, I’ve been wondering if nextcloud utilizes ionotify for realtime file change notifications?

If so, that might be a good reason to use NFS instead of an SMB mount. (I know that NFS will improve I/O performance as well, I’m not very concerned about that unless it will improve stability.)

Yeah I used the OS SMB client to mount the drives. However I didn’t mount them directly into the data folder. I mounted it in /srv/nextcloud/"folder name"
And used the local external storage feature in Nextcloud. Worked like a charm.

Didn’t this solution cause problems with permissions, e.g. a conflict between the user and www-data?


Your solution sounds better than mine. I’ll try it with future folders.


The folder is owned by root but mounted as www-data with 750 or 755 permissions. If the folder goes offline, NC won’t be able to write to it (as a further precaution a script also stops the apache webserver when shares go offline). So far, I didn’t have problems with permissions.