2

Before asking this I saw How do I recursively copy/download a whole webdav directory? but it didn't answer my questions

When I run the command, it downloads robots.txt and the very first page. This page is just a directory listing of a folder called cp. Running cat against cp, I get HTML which links to sub-directories, but none of these have downloaded.

The links are relative i.e. /dav/cp/folder but in order for them to work, I think they have to be /cp/folder

Apologies if not making myself clear enough - happy to edit where necessary.

pee2pee
  • 151

1 Answers1

3

The accepted answer that suggests to use wget on the page you mention does not use webdav and cannot do what ypu ask. Other answers mentionning davfs2 or dadaver are more correct answer, but still not complete, I think.

The key is to use webdav as a filesystem (ie a folder in the arborescence of your system). Then syncing 2 folders is as simple as rsync -aHx /some/folder/. /another/folder/. The somewhat tricky part is to get the webdav resource mounted as a filesystem. Nautilus does not really cooperate with webdav by the way.

On a 16.04 system, launch a terminal app and type the following commands

sudo apt install davfs2

Be sure to answer yes when asked if unprivileged users should be allowed to mount WebDAV resources?

If davfs is already installed and you don't remember what you answered, just

 sudo dpkg-reconfigure -plow davfs2

Then add all users that can use davfs to the davfs2 group. For example, to add yourself to the davfs2 group

sudo addgroup $USER davfs2

logout and login again. This is important as group membership is determined at login time.

Next, create a folder in your home (or somewhere else). To be sure not to use the folder without davfs, make sure the permissions are set to 0. When webdav is used, the permissions will be overridden.

mkdir -m 0 $HOME/remote

Next you need to add a line in the /etc/fstab file

echo "http://your.dav.server/path/to/resource $HOME/remote davfs noauto,user 0 0" |
  sudo tee -a /etc/fstab >/dev/null

You are now done with setup. Any time you need to use webdav, just type

mount ~/remote

remote content will then appear in the folder ~/remote. You can use nautilus, unison, or command line tools to sync the davs folder with local folder.

Don't forget to use umount ~/remotewhen you are done. davfs2 uses some cache. It must be flushed properly.

exore
  • 1,008