![]() |
cloudsync.sh, replacement to DropBox and whatever you have
Well, lately there were some threads about problems with Dropbox clients etc, and this makes me wonder...
I myself question the need to have an application and some external service just to sync my stuff. It seems a overkill, why do you need to do things the hard way when same (or better) functionality can be achieved with a simple shell script? I have been syncing my data up&down with this kind of setup. This is easy to implement, portable, robust and beautiful. 1. You need to install few niceties first. This script uses rsync with a crontab trigger, so get those from rzr's Harmattan repository. (I don't know about Frematle repositories but I belive cron and rsync are there too...)
2. You need to create a pair of rsa keys and install the public key to the cloudservers users authorized_keys, just the standard stuff. I recommend creating a dummy user just for the sync purposes... 3. Here is the cloudsync.sh script, put it to your "/root" for example: Code:
#!/bin/sh Code:
G_USERNAME="your_cloudserver_username_goes_here" Code:
~ # DESCRIPTION: So, for the people who bothered to read to the end of this posting :D This script can be modified to sync any desired directories. This example syncs my:
The folder "upload" on the cloudserver is synced to "Downloads" on the users MyDocs, and same applies, anything goes. The script detects if you are on home network and uses direct connection to the cloudserver if so. Of course that works this way for me because I have my servers on the same subnet as my WLAN. You might want to modify that setup based on your network configuration... The crontab entry launches cloudsync every 30 minutes, and additionaly it can be launched at any given moment directly. The script creates a lockfile in /var/lock to prevent double invocation. Security related thingies;
|
Re: Arch Linux ARM on N900
Good job......juicy buddy
|
Re: cloudsync.sh, replacement to DropBox and whatever you have
This is cool. The one thing I like about dropbox, though is that it is 'event-based'. E.g, put a file there, and the kernel knows and does the sync then and there.
Perhaps you could use a python wrapper or something that uses inotify and then the same effect could be achieved without cron. Just an idea. |
Re: cloudsync.sh, replacement to DropBox and whatever you have
I had a such project to do this over webdav ...
|
Re: cloudsync.sh, replacement to DropBox and whatever you have
Quote:
On the other hand, if there's something on the cloud end that needs to be synced immeiately to the phone it's a trickier situation. If that's needed then the phone would have to poll the remonte end at some shortish interval which is a sure battery killer. |
Re: cloudsync.sh, replacement to DropBox and whatever you have
Quote:
I guess normally dropbox reacts when you copy a file to the wtched directory, but what if a file is modified in the directory, should it be uploaded immediately? |
Re: cloudsync.sh, replacement to DropBox and whatever you have
Last time I tried to implement my own sync solution with rsync I stumbled upon the inability of rsync to track deleted files in two way syncs. If you pass -delete it deletes missing files for both ends regardless if a file is new on one side. I resorted to using unison, which works like a charm four-way between my windows pc, ubuntu box, N900 and macbook. I suppose that compiling it for N9 should be trivial, if the debian binary doesn't work oob.
|
Re: cloudsync.sh, replacement to DropBox and whatever you have
Yes, it might get tricky if you want to handle more than just updates. That's the reason I just upsync stuff most of the time, and I have separate directory for things to download to the device from cloud.
Here is a quick&dirty solution for monitoring a directory (/home/user/mydocs/Upload/) and immediately syncing the content to cloud if a new file is dropped there: Code:
#!/usr/bin/python Code:
G_LOGTAG="cloudsync" |
Re: cloudsync.sh, replacement to DropBox and whatever you have
While on topic, would anybody here want to try to evaluate sparkleshare for fremantle and harmattan?
|
Just a question:
When you update an existing file, do you upload/download a whole file or just the part of the file that changed? |
Re: cloudsync.sh, replacement to DropBox and whatever you have
Quote:
As far as I know (and now checking from wikipedia confirms this) the linux rsync divides all files into fixed size blocks and only transmits the differing blocks based on checksumming algorithm. (source: http://en.wikipedia.org/wiki/Rsync, see the section "Determining which parts of a file have changed") A short test of my own; I transferred a binary file of about 9MB with cloudsync.sh, then hexedited it so that I changed just one byte somewhere about middle of the file, and resent it. Code:
Apr 29 08:25:50 (2013) cloudsync: Triggered upload from filesystem The "speedup is 273.79" means that the filesize/(sent_bytes+received_bytes) = 273.79, so only 2.7% of the total file size needed to be sent on the second round. |
Re: cloudsync.sh, replacement to DropBox and whatever you have
First of all, thanks for the script. After using it for some time I wanted to have easy access to the log, as well as a way of knowing when a sync is done. This is how I do it:
1) Redirect all output/logging to a log file (.txt extension) 2) After removing the lock file, open the txt-file via xdg-open (launches the document viewer) Code:
G_LOGFILE="/home/user/logs/cloudsync.txt" |
Re: cloudsync.sh, replacement to DropBox and whatever you have
Would this still work? I'm thinking about dropping the owncloud cli-tool and use this. Since currently owncloud is holding me back from using newer vers of nextcloud on the desktop.
x |
Re: cloudsync.sh, replacement to DropBox and whatever you have
Quote:
|
Re: cloudsync.sh, replacement to DropBox and whatever you have
Okay I might need your assistance once I get around to trying this. Since I'm hoping to have it sync in both ways. which I know you didn't want for your use.
Would be amazing if I could get this going reliably. Since I then can still sync my caldav & cardiac with the newer nextcloud and then all is well again. x |
All times are GMT. The time now is 17:36. |
vBulletin® Version 3.8.8