# Sync on SMB: Server is overwriting clients files

**URL:** <https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673>\
**Category:** ℹ️ Support\
**Created:** [January 17, 2017, 6:34pm UTC](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673 "2017-01-17T18:34:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Catsrules](https://help.nextcloud.com/letter_avatar/catsrules/32/5_5575768a8748004e209b776fc1b2916d.png) [@Catsrules](https://help.nextcloud.com/u/Catsrules)\
**Post date:** [January 17, 2017, 6:34pm UTC](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673/1 "2017-01-17T18:34:52Z")

</div>

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

> [@Owncloud Sync constantly detecting changes in mounted CIFS](https://help.nextcloud.com/t/owncloud-sync-constantly-detecting-changes-in-mounted-cifs/1293):
>
> I’ve tested this on a VM with perfect clock sync both with Debian/CentOS and Owncloud 9 and now Nextcloud 9: Any Owncloud client that I use constantly detects changed files on the CIFS shares. It then decides to download all files again and again. The linux client tells me there’s a file conflict and asks whether the local or remote files should win. The Windows client just downloads over and over again. This is even when NO files have been changed. Does anyone have any ideas to stop this …

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

Clients  
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?

---

<div class="post-metadata">

**Author:** ![SPeedY](https://help.nextcloud.com/letter_avatar/speedy/32/5_5575768a8748004e209b776fc1b2916d.png) [@SPeedY](https://help.nextcloud.com/u/SPeedY)\
**Post date:** [January 17, 2017, 6:41pm UTC](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673/2 "2017-01-17T18:41:53Z")

</div>

> [@Catsrules](#):
>
> plicate the pro

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

---

<div class="post-metadata">

**Author:** ![Catsrules](https://help.nextcloud.com/letter_avatar/catsrules/32/5_5575768a8748004e209b776fc1b2916d.png) [@Catsrules](https://help.nextcloud.com/u/Catsrules)\
**Post date:** [January 17, 2017, 6:55pm UTC](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673/3 "2017-01-17T18:55:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Catsrules](https://help.nextcloud.com/letter_avatar/catsrules/32/5_5575768a8748004e209b776fc1b2916d.png) [@Catsrules](https://help.nextcloud.com/u/Catsrules)\
**Post date:** [January 20, 2017, 10:07pm UTC](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673/4 "2017-01-20T22:07:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![twentyninehairs](https://help.nextcloud.com/user_avatar/help.nextcloud.com/twentyninehairs/32/54834_2.png) [@twentyninehairs](https://help.nextcloud.com/u/twentyninehairs)\
**Post date:** [February 1, 2017, 12:56pm UTC](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673/5 "2017-02-01T12:56:16Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![twentyninehairs](https://help.nextcloud.com/user_avatar/help.nextcloud.com/twentyninehairs/32/54834_2.png) [@twentyninehairs](https://help.nextcloud.com/u/twentyninehairs)\
**Post date:** [February 1, 2017, 1:05pm UTC](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673/6 "2017-02-01T13:05:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![twentyninehairs](https://help.nextcloud.com/user_avatar/help.nextcloud.com/twentyninehairs/32/54834_2.png) [@twentyninehairs](https://help.nextcloud.com/u/twentyninehairs)\
**Post date:** [February 1, 2017, 1:45pm UTC](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673/7 "2017-02-01T13:45:05Z")

</div>

My nextcloud server itself actually has a very good hardware clock. I think I’ll sync that server to [us.pool.ntp.org](http://us.pool.ntp.org), 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.

---

<div class="post-metadata">

**Author:** ![twentyninehairs](https://help.nextcloud.com/user_avatar/help.nextcloud.com/twentyninehairs/32/54834_2.png) [@twentyninehairs](https://help.nextcloud.com/u/twentyninehairs)\
**Post date:** [February 1, 2017, 4:51pm UTC](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673/8 "2017-02-01T16:51:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![wobblywob](https://help.nextcloud.com/letter_avatar/wobblywob/32/5_5575768a8748004e209b776fc1b2916d.png) [@wobblywob](https://help.nextcloud.com/u/wobblywob)\
**Post date:** [February 13, 2017, 5:31pm UTC](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673/9 "2017-02-13T17:31:58Z")

</div>

I had the same problem as you (f[orum link](https://help.nextcloud.com/t/wrong-date-for-files-created-on-smb-external-storage/7552)). 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.

---

<div class="post-metadata">

**Author:** ![Catsrules](https://help.nextcloud.com/letter_avatar/catsrules/32/5_5575768a8748004e209b776fc1b2916d.png) [@Catsrules](https://help.nextcloud.com/u/Catsrules)\
**Post date:** [February 13, 2017, 6:35pm UTC](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673/10 "2017-02-13T18:35:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![twentyninehairs](https://help.nextcloud.com/user_avatar/help.nextcloud.com/twentyninehairs/32/54834_2.png) [@twentyninehairs](https://help.nextcloud.com/u/twentyninehairs)\
**Post date:** [February 15, 2017, 9:55am UTC](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673/11 "2017-02-15T09:55:11Z")

</div>

@wobblywob

- 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.

---

<div class="post-metadata">

**Author:** ![JasonBayton](https://help.nextcloud.com/user_avatar/help.nextcloud.com/jasonbayton/32/297_2.png) [@JasonBayton](https://help.nextcloud.com/u/JasonBayton)\
**Post date:** [February 15, 2017, 10:20am UTC](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673/12 "2017-02-15T10:20:47Z")

</div>

> [@wobblywob](#):
>
> I’ve setup normal samba shares inside nextcloud/data/[username]/[foldername]

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.

---

<div class="post-metadata">

**Author:** ![wobblywob](https://help.nextcloud.com/letter_avatar/wobblywob/32/5_5575768a8748004e209b776fc1b2916d.png) [@wobblywob](https://help.nextcloud.com/u/wobblywob)\
**Post date:** [February 15, 2017, 11:42am UTC](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673/13 "2017-02-15T11:42:42Z")

</div>

@twentyninehairs

- 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.

@JasonBayton

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.

---

<div class="post-metadata">

**Author:** ![JasonBayton](https://help.nextcloud.com/user_avatar/help.nextcloud.com/jasonbayton/32/297_2.png) [@JasonBayton](https://help.nextcloud.com/u/JasonBayton)\
**Post date:** [February 15, 2017, 11:59am UTC](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673/14 "2017-02-15T11:59:37Z")

</div>

That’s fine, just so you know 🙂

---

<div class="post-metadata">

**Author:** ![wobblywob](https://help.nextcloud.com/letter_avatar/wobblywob/32/5_5575768a8748004e209b776fc1b2916d.png) [@wobblywob](https://help.nextcloud.com/u/wobblywob)\
**Post date:** [February 15, 2017, 12:19pm UTC](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673/15 "2017-02-15T12:19:22Z")

</div>

@JasonBayton

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.

---

<div class="post-metadata">

**Author:** ![twentyninehairs](https://help.nextcloud.com/user_avatar/help.nextcloud.com/twentyninehairs/32/54834_2.png) [@twentyninehairs](https://help.nextcloud.com/u/twentyninehairs)\
**Post date:** [February 15, 2017, 12:23pm UTC](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673/16 "2017-02-15T12:23:02Z")

</div>

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.)

---

<div class="post-metadata">

**Author:** ![Catsrules](https://help.nextcloud.com/letter_avatar/catsrules/32/5_5575768a8748004e209b776fc1b2916d.png) [@Catsrules](https://help.nextcloud.com/u/Catsrules)\
**Post date:** [February 15, 2017, 11:23pm UTC](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673/17 "2017-02-15T23:23:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bjo](https://help.nextcloud.com/user_avatar/help.nextcloud.com/bjo/32/2754_2.png) [@bjo](https://help.nextcloud.com/u/bjo)\
**Post date:** [February 16, 2017, 8:51am UTC](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673/18 "2017-02-16T08:51:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![wobblywob](https://help.nextcloud.com/letter_avatar/wobblywob/32/5_5575768a8748004e209b776fc1b2916d.png) [@wobblywob](https://help.nextcloud.com/u/wobblywob)\
**Post date:** [February 22, 2017, 10:31am UTC](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673/19 "2017-02-22T10:31:51Z")

</div>

@Catsrules

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

@bjo

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.

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 2, 2024, 12:36pm UTC](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673/20 "2024-12-02T12:36:22Z")

</div>



[Next page](https://help.nextcloud.com/t/sync-on-smb-server-is-overwriting-clients-files/7673.md?page=2)
