Headless Command Line Sync for ownCloud on Linux

Headless Command Line Sync for ownCloud on Linux

This article has been updated: The new article covers version 8 of OwnCloud.

ownCloud is a great way for paranoid people like me to run their own Dropbox-like service. It allows you to host your own files on a server that you can easily sync between desktops and mobile devices, and it's completely cross-platform!

The biggest challenge though was that documentation for how to run an ownCloud client on a headless Linux installation that doesn't have X installed is few and far between. But, it turns out it's really easy to do!

First, simply install the ownCloud client on your Linux headless server that you wish to sync it's data with your ownCloud server. It will install a few dependencies, but not a full Xorg installation so nothing to worry about.

Next, create a config file somewhere in your home directory. I created it as:

/home/tony/.owncloud/owncloud.cfg

In that file put something like the following:

[General]

[ownCloud]
url=https://my.cloud.url.com/
http_user=tony
authType=http
user=tony

Obviously replace the URL with the actual URL to your server. Honestly though I'm not even sure it's needed.

Create a local directory that you wish to use to store your ownCloud files within:

mkdir /home/tony/ownCloud

And run your first sync just to test the process:

owncloudcmd --confdir /home/tony/.owncloud/owncloud.cfg /home/tony/ownCloud 
   ownclouds://tony:password123my.cloud.url.com/remote.php/webdav

If all goes well, your ownCloud storage should sync down to the local machine, and every time you run that command changes will sync both up and down.

Finally, place that command on a cron job to run hourly, daily, or at whatever interval you can stand. If you're using it for backups like I do, then running nightly at 1 AM might be appropriate.

Keep in mind: this method exposes your cleartext password in the command line. It's not the most secure way of doing things. If you want to amp up the security a bit you can put your password into a file that only you can read, among other things.

If you want to only sync part of your ownCloud repository, you can specify a different remote path by tagging it to the end of the webdav URL like so:

owncloudcmd --confdir /home/tony/.owncloud/owncloud.cfg /home/tony/ownCloud 
   ownclouds://tony:password123my.cloud.url.com/remote.php/webdav/deeper/path/in/storage
Posted by Tony on May 14, 2014 | OwnCloud