7

I have mounted a webdav directory with davfs2 via:

sudo mount -t davfs -o uid=bruni,gid=users https://server/folder /home/bruni/mountpoint/

How can I force a sync via command line without unmounting the directory?

The client is running KUbuntu 19.10, the server is an egroupware server but this is most probably irrelevant.

mount.davfs -V                                                                                                                                                                      
davfs2 1.5.5  <http://savannah.nongnu.org/projects/davfs2>

To clarify what I mean by synchronize, I mean what umount.davfs, does before unmounting to verify that all changes have been uploaded to the server:

/sbin/umount.davfs: waiting while mount.davfs (pid xxxxx) synchronizes the cache .. OK
Bruni
  • 185
  • 1
  • 7
  • I don't have a davfs system to test here, but have you tried `sudo sync /home/bruni/mountpoint` ? – Zip Dec 23 '19 at 01:32
  • @Zip i get `sync: error opening '/home/bruni/mountpoint': Transport endpoint is not connected` (the share is mounted) – Bruni Dec 23 '19 at 09:44
  • 1
    Perhaps it is getting timeouts during the sync operation or some other issue. I suggest you enable debug as indicated in the [davfs man page](https://linux.die.net/man/5/davfs2.conf) and retry the operations. That way you may be able to diagnose further what is happening here, as that error doesn't indicate its source cause. Edit your question with that info if possible. – Zip Dec 23 '19 at 20:26
  • Thank you and sorry for answering so late. I have enabled debugging. Strangely 'sudo sync /home/bruni/mountpoint' no longer returns an error. It returns nothing at all, though maybe I did not perform any write operation. – Bruni Dec 31 '19 at 16:35
  • Silence in the unix universe usually means success. After the sync command run `echo $?`. If it returns 0 you can assume it worked, but you must make sure your test does actually test what you need. – Zip Jan 01 '20 at 18:30
  • echo $ gives 0. You can sum this up in an answer. Thank you and a happy new year! – Bruni Jan 02 '20 at 10:04
  • 2
    The error `Transport endpoint is not connected` means that the process managing the connection has died unexpectedly. The kernel thinks the filesystem is still mounted but there is nothing handling I/O to the target device. – roaima Jan 03 '20 at 14:04

2 Answers2

2

To force synchronization of a mountpoint you can use the sync command, as for you it could be:

sudo sync /home/bruni/mountpoint

This command will attempt to write all uncommitted data at the moment, similar to the "safe removal" for removable drives.

For davfs in particular, if you have issues, there is a debug flag you can set as you mount the volume which should help with diagnostics.

If there are no errors on your logs or console as you sync the mountpoint and the returncode for it is 0, you can assume it worked.

Zip
  • 962
  • 6
  • 16
0

I registered just to say thanks to Zip!

for me a combination of this: sync /root/mountpoint

and then: umount /root/mountpoint

Caused an output of: /sbin/umount.davfs: waiting while mount.davfs (pid 21) synchronizes the cache .. OK Unmounted

And the files FINALLY appeared for me in NextCloud.

Seriously, thank you!

  • Please don't add "thank you" as an answer. Once you have sufficient [reputation](https://unix.stackexchange.com/help/whats-reputation), you will be able to [vote up questions and answers](https://unix.stackexchange.com/help/privileges/vote-up) that you found helpful. - [From Review](/review/late-answers/417118) – G-Man Says 'Reinstate Monica' Jul 01 '22 at 02:50