In Sync Hacks, we spotlight cool uses of Sync from the creative minds of our users. Sync is our free, unlimited, and secure file-syncing application. If you have an interesting use or how-to, shoot us an email at sync[at]bittorrent.com. Can’t wait to hear what you guys cook up.
In this week’s edition of Sync Hacks, Jack Minardi shows us how to “create your own Dropbox” using BitTorrent Sync and Raspberry Pi. He needed to keep his notes synced safely – without worrying about data loss. So, he turned to BitTorrent Sync: the safest way to keep files up to date across devices. Read on to see how he did it!
Or visit his original post here.
The Problem
I like to take long running notes, jotting down an idea here and there when
one pops up. I never know which devices I will have with me, so I like to have
these notes synced across all of them.Previously I had been using the Chrome plugin QuickNote which is a light weight interface on top of the diigo cloud service. I had been using it for about two years and never had a problem until a few days ago. I somehow managed to lose about three months of edits. I still have not quite shaken that feeling of despair knowing I will never get my data back, but it did finally force me to beef up my note-syncing system. While I will primarily be using this setup to sync notes, it is by no means limited to only text files.
Enter Resilio Sync (aka BitTorrent Sync)
Installing BitTorrent Sync on the Raspberry Pi
You need to grab the ARM
build of
BitTorrent Sync:mkdir ~/.btsync && cd ~/.btsync wget http://btsync.s3-website-us-east-1.amazonaws.com/btsync_arm.tar.gz tar -xfv btsync_arm.tar.gzUnless you have a large SD in your Pi you will probably want to use an external
drive for your sync location. I will be using a USB thumb drive. You may need
to format your thumb drive as EXT4 if you are having issues. (WARNING! This
will erase all data on your drive)df -h # find your drive here, e.g. `sda1` sudo umount /dev/sda1 # replace sda1 with your drive name ! sudo mkfs.ext4 /dev/sda1 -L BTSync # replace sda1 with your drive name !Now all you have to do is launch the btsync application and you will be up and
running!cd ~/.btsync sudo ./btsync # can be killed with `sudo killall btsync`If you see the following output btsync is properly running.
BitTorrent Sync forked to background. pid = 3003Navigate your browser to
Your-Pi-IP-Address:8888/gui
to manage the btsync
process. To add the thumb drive select “Add Folder” and navigate to
/media/BTSync
. You will need to generate a secret as this is the first time
you are adding the folder.
Other Devices
Now go download the Android app and/or the desktop app and connect them using the secret you just generated It’s that simple! Any change on any device will be synced across all online devices. If you keep your Pi online it will store and push the most up to date content as your other devices go on and off line.
Extra Credit
Start at Boot
You may want to set btsync to start when you boot your Raspberry Pi. To do that
we will place a script in/etc/init.d/
and then register it with
update-rc.d
.sudo nano /etc/init.d/btsyncPaste the following code in the script
#! /bin/sh # /etc/init.d/btsync # # Carry out specific functions when asked to by the system case "$1" in start) /home/pi/.btsync/btsync ;; stop) killall btsync ;; *) echo "Usage: /etc/init.d/btsync {start|stop}" exit 1 ;; esac exit 0Then change the permissions, test, and register it to run at boot:
sudo chmod 755 /etc/init.d/btsync sudo /etc/init.d/btsync start # test that the script starts sudo /etc/init.d/btsync stop # test that the script stops sudo update-rc.d btsync defaults
Password Protect Web Interface
If you expose your web interface to the outside world (or if you don’t trust
your friends) you are going to want to password protect it. This can be done
with a btsync config file passed to the executable at runtime with the
--config
flag. First, use btsync to generate a sample config file, modify it
to fit your needs, and restart the process.cd ~/.btsync ./btsync --dump-sample-config > btsync.conf # browse the sample config file and change what you want sudo killall btsync sudo ./btsync --config btsync.confHINT: Use jsonlint to validate your config file if
btsync complains. Also make sure to modify the/etc/init.d/btsync
script to
use the config file as well.Questions? Hit me up on twitter (@jackminardi)
Jack Minardi (@jackminardi) is a scientific software developer and hardware hacker from Austin, TX. He is interested in product development, user experience design, and expanding the human-computer interface. You can find his personal blog here: jack.minardi.org