My internet connection is not really the best and I have to sync about 50GB of data with my owncloud. To achieve this, I have flashed my TP-LINK WR1043ND to OpenWrt „Backfire 10.03.1“ and attached my external harddrive to it. Now I can sync the files even if the PC is not running. But OpenWrt does not provide a webdav client like davfs, so I have to sync directly via ssh and rsync. Well – that should work, right? NO. Owncloud is not able to re-scan the file-system for changes. You will always have to truncate the fs_filecache table and that is really annoying.
On my Owncloud server I am running Ubuntu 12.04 which has support for davfs. So I have installed davfs2
sudo apt-get install ca-certificates davfs2
and created a new folder (/home/owncloudsync/rsync_to_webdav) as sync destination.
Then just mount the new folder via webdav to your Owncloud:
sudo mount -t davfs http://localhost/owncloud/remote.php/webdav /home/owncloudsync/rsync_to_webdav -o uid=owncloudsync
owncloudsync is the username for the ssh connection from router to server.
Now, if my router syncs the files to /home/owncloudsync/rsync_to_webdav, they will automatically be trans-fared to Owncloud via webdav. And Owncloud does detect all changes that where made to webdav!
This solution is not the fastest – but its working.
Here is a quick manual how to setup public key authentification with dropbear ssh:
I found plenty of examples on setting up key based authentication using dropbear as the HOST, but not as the CLIENT. Here’s how I did it:
This assumes that the OpenWRT device is named ‘nas’ and the remote machine is ‘webhost’. The goal is to allow ‘nas’ to authenticate to ‘webhost’ using a key instead of a password.
First, generate your identity key on ‘nas’
dropbearkey -t rsa -f ~/.ssh/id_rsa
Since dropbear stores its keys in different format, it needs to be converted for a standard SSH server:
dropbearkey -y -f ~/.ssh/id_rsa | grep "^ssh-rsa " >> authorized_keys
Now copy or (concatenate) ‘authorized_keys’ to ~/.ssh on ‘webhost’. Ensure that permissions on this file are set to 600. You should now be able to ssh without a password. Paste it to /home/user/.ssh/authorized_keys!
root@nas:~# ssh user@webhost -i ~/.ssh/id_rsa
Notice that you need to explicitly specify the identity file on the command line. Dropbear does not automatically look for it like OpenSSH does.
Now that ssh works, I can easily perform an automated rsync:
rsync -rlptD -v -z -e “ssh -i /root/.ssh/id_rsa” some-file-here.txt user@webhost:some-file-there.txt
To run that sync in background, use screen.
Hope that helps!