I use BingoDisk as a backup and remote storage solution and wanted to use it as the destination for my daily backup of this blog and my development environment. BingoDisk is available via WebDAV which is nice and convenient, and there are 2 main options for Ubuntu, davfs2 and fusedav.

On the face of it, davfs2 is more convenient, as it allows you to automount quite easily using fstab. However, despite a number of attempts, I couldn’t convince it to allow me to write files remotely, only folders. It seems a number of people have had the same issue.

Fusedav, on the other hand, was much more reliable, writing files and folders without errors. It also seemed noticeably faster. Unfortunately, there didn’t seem to be any convenient way to mount the share automatically, and this would be important for my automated backup routine. To solve this, I put together a quick solution using a simple mount description file and an init script that gives me better control over the process. The idea and parts of the code are built on a solution I found by müzso. This goes one step further and enables it to run automatically at boot time.

Below are the steps I took, and the script I’m using. The steps are for Ubuntu, but should be easily modifiable to any flavour of Linux.

First, install fusedav.

sudo aptitude -y install fusedav

Next, we do a quick test to check that fusedav will indeed connect to our WebDAV share.

We’re running fusedav in the foreground because it will be easier to kill that way once we’ve finished testing, so open a new terminal and check that you can connect.

cd /mnt/bingo
ls -la

If all is well, the top level of your remote share should now be visible. I don’t like that you have to specify the password on the command line, but there doesn’t seem to be too much you can do about that at the moment.

Close the second terminal, and kill the fusedav process in the first by pressing Ctrl+c. Now, we’re going to create a directory and a simple mount description file that includes the URL, username and password. I’m going to call the file bingo, and later on this means that the share will be mounted at /mnt/bingo. The directory layout I went for is similar to how Apache and Nginx manage virtual hosts.

mkdir -p /etc/fusedav/mounts-available

Now edit /etc/fusedav/mounts-available/bingo as root using your favourite text editor and put the following in it. The 3 segments are the URL to the WebDAV location, username and password, separated by a space.

http://mydomain.bingodisk.com username password

Because this file contains your password in plaintext, you should secure it so that only the owner (root) can read it.

sudo chmod 600 /etc/fusedav/mounts-available/bingo

Next, the init script, which you can download from here. You need to make it executable.

You can take a look at the file in its entirety. It’s not especially complex but the highlights are:

NAME=bingo

You should alter bingo on this line to be the same as the name of the file you put in /etc/fusedav/mounts-available. This is the only change you have to make (and you only have to make it if you called your mount something other than bingo).

MOUNT_FILE=/etc/fusedav/mounts-available/$NAME
MOUNT_POINT=/mnt/$NAME

These lines define where the mount description files are kept and where the share will be mounted.

This section splits the mount description into usable variables and sets the parameters for fusedav.

The script automatically creates a PID file which should help avoid any issues if you start the daemon more than once. It also starts fusedav as a background process, so it doesn’t interfere with your terminal.

Let’s check that the script works.

su -
/etc/init.d/bingo start
cd /mnt/bingo/
ls -la

Hopefully, at this point you should see the remote share, as before.

Finally, we can add the script to the default runlevel so that it starts when the server boots up.

sudo /usr/sbin/update-rc.d -f bingo defaults

And that should be that! If you need to stop the daemon use the following.

sudo /etc/init.d/bingo stop

You can easily add further shares if necessary with the following steps as root (assuming the new share name of bongo).

Thank you for this post! This is exactly what I wanted. My only issue is that the FuseDAV drive is mounted with root:root as the owner and group and when I attempt to “chown it” I get an error. Is there a way for this to be mounted with root:users as the owner and group?

Great post.
I tried mount.cifs, davfs2, all of them gave me heart ache. Followed you post, was easy and looks like it works. I have run into one problem and not sure if I can ignore it:
after executing the : su /etc/init.d/bingo start #(I changed the name from bingo…)
got the following error msg: Unkown id: /etc/init.d/bingo

checked the var/run directory > there is no bingo.pid file
checked the script and it says in the start section: and it the PID file does not exist it should create it. Do you have any idea what is wrong?

Couple of things to try. Firstly, try the script exactly as is (i.e., without renaming bingo) and see if that works. If that works then you can move onto renaming. Have you granted +x permissions on /etc/init.d/your-name ? Have you changed $NAME in /etc/init.d/your-name to ‘your-name’?

The final code block in the post shows an example of how to take a working mount definition ‘bingo’ and copy it to create another one. Did that work? If you don’t want the bingo script lying around, you can use ‘mv’ instead of ‘cp’ on the first line.

Thanks a lot. This really saved my day.I had but one inconvenience and that is that the share was only readable by root. Since I do not like running Nautilus as root, I removed the script from startup and start it manually as a normal user. Of course, I had to change permissions on the file with the URL and password information, but it is reasonably well hidden. In order to create the .pid file I also had to make /var/run writable.

[…] Here is a good tutorial show you how to Automatically Mounting WebDAV in Ubuntu with a FuseDAV Init Script: the face of it, davfs2 is more convenient, as it allows you to automount quite easily using fstab. However, despite a number of attempts, I couldn’t convince it to allow me to write files remotely, only folders. It seems a number of people have had the same issue. […]

Yeah, it’s not perfect. As I note above, because you type the password on the command line it is plainly visible in many ways – even htop will reveal it. I’m not aware at the moment of anyway of calling fusedav without specifying a password. Would be happy to hear otherwise.

As for permissions, off the top of my head, you could create a low privilege account and give it ownership of the mount. Then, instead of using sudo the command in the init script, use su newaccountname -c ‘fusedav …’