CIFS/SMB sync with Client app


#1

Hi,

I suppose this is normal behavior but it is a big issue with my situation.

I have nextcloud installed on a vmware virtual server (Ubuntu 16.04)
I don’t host files on that server I only create SMB connections to my existing Windows 2003/2012 shares.

When I connect the Windows client to these “External storages” for syncing locally. It actually don’t sync at all. It will just push local new or modified files/folders to the remote share.
When I create or modify files/folders directly on the remote share, the client won’t be able to see that something changed and will not pull these files/folders.

The only way to wake it up is to log into the web interface and browse to the Windows share which will eventually tell the client that something changed.

The way we work here is that people with laptops will have a synced version of some shared folders in which they will work on locally when away. But they are, most of the time, working directly to these shared folders when they connect to their Remote Desktop session. I had no intention of giving them access to the web interface.

So I need that the client be able to look frequently at the remote shares for new and modified files/folders in this particular situation.

Thank you


#2

You do need to enable the SMB update notifications. https://docs.nextcloud.com/server/13/admin_manual/configuration_files/external_storage/smb.html


#3

Thanks for the reply. This is good I guess but it is very challenging for me.
For example: it says my smbclient is already the newest version (2:4.3.11+dfsg-0ubuntu0.16.04.13)
When I type occ files_external:list it says that occ: command not found

Can’t it be implemented so we don’t need to do manual work?


#4

I guess you can only add your case to the issues: https://github.com/nextcloud/server/issues/8978 or pay for a subscription with Nextcloud GmbH …


#5

OCC
occ is an executable PHP file in Nextcloud’s base folder (/var/www/nextcloud usually), so it’s not in the $PATH for most systems. More info in using the OCC command.

I like to open it directly with php, and I need to run it as my Apache web server user, so this is what I’d type in order to run the command you gave:
sudo -u www-data php /var/www/nextcloud/occ files_external:list

It does look like your smbclient package is higher than version 4, so that should work fine. Do you also have libsmbclient-php installed?

Re: Manual Work
It can be implemented to not need ongoing work by you, only the one-time setup. If you’re able to complete the instructions on that page, you can automate Nextcloud’s rescan process.

Near the bottom of the page that @Escubaer linked to, under Decrease Sync Delay, you’ll see this command:
occ files:scan --unscanned --all

If you’ve already followed the guide to set up cron as your job scheduler, then you’ll know how to add that command to your crontab (if not, you just run crontab -u www-data -e and add the appropriate line in your text editor). Here’s what that command snippet from earlier looks like on my installation, set to run every 15 minutes:
*/15 * * * * php /var/www/nextcloud/occ files:scan --unscanned --all


#6

Thanks for the info.
I don’t know if I have libsmbclient_php installed but when I try to install "apt-get install libsmbclient_php "
I get “E: Unable to locate package libsmbclient_php”

For the “guide to set up cron” I really don’t understand much of what I can read there. This kind of thing is too complicated for me.

Most of the time when I follow instructions like that I have to completely trust that there are no typo in the instructions because I’m only copy pasting everything without really understanding what it does.
So, If I make mistakes I don’t know where or when I made a mistake and I can’t really know how to revert back.

So I try not to do too much changes manually like that.

If there was a checkbox in the web interface settings (to do just that) it would really help people like me.


#7

We don’t use syncing, but if it relies on WebDAV, that has been broken for SMB external storage since version 12. The last 11 release works, but none of the 12 or 13 releases do.


#8

Looks like I made that libsmbclient_php rather than libsmbclient-smb, that would indeed be a typo on my part. The exact, proper name of that library is on that same SMB/CIFS doc page that was first linked.

I understand that you’re trying to run and use Nextcloud, not get a general Linux education. This even seems like a common thing to try to do, but that doesn’t mean it’s simple to configure, even for Linux pros. We Linux people generally have a lot of assumed knowledge and troubleshooting experience baked into our suggestions, which is frustrating to account for on both sides.

Nextcloud is very good with its installation documentation compared to most projects like it, and does provide a fair bit of copy/paste commands, but many pages like that SMB one would have to make quite a few assumptions in order to give verbatim commands to run, and building those assumptions into the code to make a checkbox that makes the complex changes for you could be quite hairy. The existing “scan the files I look at” check-box does what it does, but it’s not a complete solution, you’re right. As suggested, you could open a GitHub ticket and see if someone tackles this, but you’d be unlikely to see code changes until the next major release.

You might be interested in the nextcloud snap, which is configured based on assumptions that work for most people in the basic case, and so the project is able to provide verbatim commands on its wiki pages (and maybe checkboxes in future, but not there yet). I don’t think it has the SMB update notifications configured though (common, but not used still by most people and as said, complex), so you might need something a little less prescriptive in this case.

A little bit more involved and a lot more flexible, you could run a VM with a pre-configured image whether provided by Nextcloud or a trusted third party. I’m not sure if this particular image has SMB notifications set up, but I’m sure someone has a version with it pre-configured out there.

The last option I see (and others can feel free to jump in if I missed some) would be to pay for someone’s time to do the behind-the-scenes work. You could sponsor someone to write the code to provide a check-box, or more immediate to your case, to do the configuration for you directly. Nextcloud gmbh would be the natural choice, and they offer full support plans at nextcloud.com.


#9

Hi, I really appreciate the time you spent to reply to me.
I stumbled on this app in the +App list “INotify”
https://apps.nextcloud.com/apps/files_inotify

I managed to enable it.

It seems to me that it is exactly what I’m looking for.

I hope it is.

Thanks


#10

Update: So far, nothing I tried worked. I still have the inotify app enabled but it does not seem to change anything.

I will wait for the release of version 14 and hope for the best.


#11

Just to make sure, have you followed the instructions on that app’s README, and have you verified its command is indeed running in the background?


#12

I’m not sure I understand these instructions.

Do I need to run manually occ files_external:notify -v on every network share I added? (So far I only have 12 but I expect to have a lot more in the future)
I thought that it was the purpose of the app.

Also, on 1 share I get an error when I run it:
Error while running self-test, change is subfolder not detected

And when I stop it (ctrl-c) I get this:
[Icewind\SMB\Exception\ConnectException]
Unknown error (WARNING: The “syslog” option is deprecated
Domain=[] OS=[Windows 6.1] Server=[Samba 4.4.16])


#13

That would indeed appear to be the case, based on this from the README:

To detect changes you need to run the files_external:notify command for the configured local external storage.

That said, this looks like it’s only for local external storage, and not for SMB at all. That would be why it can’t detect a change in the subfolder (your first error message). Sorry, but I don’t think this one’s what you were looking for.


#14

Thanks, that error was only on 1 of my shares. It does work on all the other. The difference is that the working shares are located on a Windows 2003 server and the one giving me the error is located on a 2012 server.