Official website

Friday, February 10, 2017

Dropbox alternative for ARM Linux and Jubito integration

Once upon a time, when a netbook (Dell mini 9) with Ubuntu was my Jubito server, I used dropbox to sync my important files, such as camera video recordings of my security system. Then I migrated to a Banana Pi and currently to Banana Pro. Both derivatives of Raspberry Pi. Unfortunately dropbox has no support or plans for ARM Linux variants. A quick solution was to use ownCloud. All went well till ownCloud client stopped syncing for a number of reasons (incompatible updates/upgrades,etc).

I've made an effort to find out a solution that suits me and finally rclone came up.
Rclone is a command line program that sync files and directories to and from, and it comes with support of various storage systems (google drive, dropbox, Microsoft One Drive and more). My desirable choice is dropbox, so,  I started getting my hands wet.
I read of course that I would just have to perform the sync operation manually when I wanted things up to date but it didn't bother me in first place. I'll explain the reason afterwards.

Let's proceed to step by step process.

Download rclone to your home directory, unzip it and move forward to next paragraph, or go through command line.

cd
wget -c http://downloads.rclone.org/rclone-v1.35-linux-arm.zip
unzip rclone-v1.35-linux-arm.zip
Rename the directory for sake of simplicity
sudo mv /home/<user>/rclone-v1.35-linux-arm /home/<user>/rclone
cd rclone
Change file access permissions
sudo chmod 755 /home/<user>/rclone/rclone

Follow installation and configuration instructions. The guide use a generic name for the remote target, called remote. As I chose dropbox installation, I will call it dropbox instead.

After installation finishes try to synchronize your source with the destination. In this case the destination directory will be called jubito. Open a terminal and type:

./rclone sync /home/<user>/<source> dropbox:jubito

Time for Jubito integration. I will present three cases. Making a scheduled job, sync on-demand and trigger on event. Before we proceed we have to create invocation to rclone. We need a launcher that point to the action above.

Go to Settings->Instructions->Add New Launcher. On popup give as name "sync" and action like this:

./'/home/%user%/rclone/rclone' '/home/%user%/<source>
dropbox:jubito'



where <source> your current installation (in my case /home/john/bin), and press save. Dot slash (./) is a native implementation similar to Linux and Unix to execute a compiled program and %user% is a built-in function that gets the logged in username (alternatively, hard-coded your user). The result, if any, can be consumed by another Instruction Set. Learn more on (incomplete) Instruction Set anatomy.
This will create a pointer to the command inside AppConfig.xml which could be used at any case (scheduled, on-demand, etc).

Calling the method from CLI:


Physical location

Dropbox location

1) Scheduled
Go to Settings->Scheduler->Add New. Enter a name, select daily routine, time (e.g. 00:00) and finally sync action. This will create a schedule that runs daily at midnight and triggers the dropbox sync.


2) On-demand
From Settings->Instructions->Add New Instruction Set. Name it "dosync" or whatever you like, select from action list the sync command we created before and press add. It will generate a *sync pointer to the sync launcher. You can put some additional text if you wish. Expand Add to Dashboard and put some info (category, header) to populate a button to the dashboard list.


Now you'll be able from menu list to press and run the sync method...

 
3) Attach to other Instruction Set
First let's make an example based on DVR system by using an IP camera example. Scenario describe operations when security breach is detected (record a video and send email alerts). To extend it with dropbox synchronization, we're going to use the sync as the third action in the sequence. So, once again add the sync launcher.

<InstructionSet id="ip-cam">{ evalBool("%whereami%" == "absent"); rec sendmemail sync; ; }</InstructionSet>

If you want to use the UI and already have the ip-cam Instruction Set, please delete it and re-create it since there is no edit mode. Else, edit AppConfig.xml and change it with the line above.

However, you can create a new ip-cam with the same condition that calls only sync method like that:

<InstructionSet id="ip-cam">{ evalBool("%whereami%" == "absent"); sync; ; }</InstructionSet>

Instructions with the same name, run in order.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.