ownCloud is enterprise file sync and share that is self-hosted in your data center, on your servers, using your storage. ownCloud provides Universal File Access through a single front-end to all of your disparate systems. Users can access company files on any device, anytime, from anywhere while IT can manage, control and audit file sharing activity to ensure security and compliance measures are met.
WebDAV (Web Distributed Authoring and Versioning) allows you to “mount” your ownCloud content as a local mount point on your local Linux environment.
I prefer this over using the ownCloud client program, as it gives me much more flexibility with my data (e.g. I can rsync directly from CLI from my local storage to the ownCloud and vice versa – effortlessly).
Here’s how I did it:
NOTE: YOU WILL NOT NEED TO BE ROOT TO USE THE MOUNT, BUT ALL OF THESE COMMANDS ASSUME YOU ARE ROOT.
THESE INSTRUCTIONS ALSO ASSUME YOU HAVE A VALID SSL CERTIFICATE FOR YOUR OWNCLOUD HOST. IF YOU DO NOT, REPLACE HTTPS WITH HTTP IN ALL INSTANCES BELOW.
1. Install davfs2
Using your Linux distribution’s package manager, install the ‘davfs2’ package which is available in most all repositories regardless of Linux flavor.
# apt-get install davfs2
# yum install davfs2
2. Create and set permissions for a local mount point for your ownCloud data.
(I prefer mine in /owncloud — replace all instances of ‘youruser’ with your non-root username)
# mkdir /owncloud
# chown youruser.youruser /owncloud
# mkdir ~youruser/.davfs2
# touch ~youruser/.davfs2/secrets
# chmod 600 ~youruser/.davfs2/secrets
# chown -R youruser.youruser ~youruser/.davfs2/
3. Edit ~youruser/.davfs2/secrets with your favorite editor to store your ownCloud credentials:
https://yourdomain.com/owncloud/remote.php/webdav youruser yourpassword
4. Edit /etc/fstab and put the following entry in to tell the filesystem how to mount it:
https://yourdomain.com/owncloud/remote.php/webdav/ /owncloud davfs user,rw,auto 0 0
Note: if you prefer to not have the mountpoint auto mounted each time you log-in, change auto to noauto
5. Add youruser to the ‘davfs2’ group so it can use it.
# usermod -aG davfs2 youruser
Note: you will need to log out and back in to get your new group to take effect
6. Now all you need to do is mount your ownCloud webdav instance
# mount /owncloud
On some operating systems, the mount.davfs binary does not have setuid privileges to run as a non-root user. If you see an error such as:
/sbin/mount.davfs: program is not setuid root
You are running an OS that needs the privileges granted. To do so, run this as root:
# chmod +s /usr/sbin/mount.davfs
Want faster rsyncs??
If you’re transferring a large amount of files with rsync, you’ll want to pass it some extra arguments.
Check the rsync man page for: