A new version of this series has been published. Please refer to the new index for updated articles and ordering. This article is kept for historical reference, but should be considered out of date.
Note: This article is part of a series. See the Index for more information.
Self-promotion: I’ve recorded this series as a screencast for Pluralsight:
If you have a Pluralsight subscription, please consider watching it. Thanks!
Updates: Change “wheezy” to “jessie” when setting up the source list. Wheezy will still work, but I would expect Jessie to be more up to date.
It may no longer necessary to manually expire your license, as newer installations no longer opt you into the pro trial by default. This also means you don’t need to worry about setting up pro features accidentally. At the time of this update, the btsync coming from the Jessie repository still set up a license for me, so I still had to expire it manually. Go look for it as instructed in the module. If you don’t find the license.bin file, then you should be all set.
There are plenty of cloud sync solutions out there. You have Microsoft’s SkyOneDrive, Google Drive, DropBox, and SpiderOak just to name a few. One thing they all have in common is that a copy of your stuff is on someone else’s system. Perhaps you’re uncomfortable with that, even if they’ve promised that they won’t peek at it. Or maybe you’re just looking for yet another thing for your Raspberry Pi to do.
The same people that brought you BitTorrent, the peer-to-peer file sharing application, have created BitTorrent Sync. It’s a file synchronization application based on the BitTorrent protocol. Think of it as a peer-to-peer network where all of the peers belong to you (Your desktop, laptop, tablet, phone, etc). If you put something in a sync folder on one computer, it shows up in the sync folder on all of the other computers.
The trouble is that in order for a file to travel from one computer to another, they both have to be up and running at the same time so that they can talk to each other. You may want to share files between work and home, but by the time you get to work, your home computer will have fallen asleep and vice versa. What you need is a node in your network that’s always on. The Raspberry Pi can be that node.
This post is going to be pretty short because, to be honest, the installation is dead simple.
Install BitTorrent Sync
There is an apt-get package available for BitTorrent sync, but it’s not listed on the well-known public repositories yet. We’ve run into this kind of problem before, when we installed Webmin in Part 4. The answer’s the same as it was then. Edit apt-get’s list of sources to add the BitTorrent Sync repository.
Rather than editing the main sources.list file, this time we’re going to create a separate file to contain just the sources used by BitTorrent Sync. This is the preferred way to keep everything separate and organized so you don’t lose track of why each entry was added to the main sources.list file. You can go back and move the Webmin repository information into its own file as well while you’re tidying up. I did.
Create a new file to contain the BitTorrent Sync repository information. This file must be in the /etc/apt/sources.list.d folder, and must have the extension .list. Name the file something that lets others know what package it was created to support.
sudo nano /etc/apt/sources.list.d/btsync.list
Add the following two lines to the file.
deb http://debian.yeasoft.net/btsync wheezy main contrib non-free deb-src http://debian.yeasoft.net/btsync wheezy main contrib non-free
Close and save the file (ctrl-x, y, enter).
As with the Webmin installation, you’ll need to import the signing key used by the new repository before you can use apt-get to install things from it. This time, the key is available from a public key server, so the commands are going to be quite different.
Import the repository’s signing key with the following commands:
sudo gpg --keyserver pgp.mit.edu --recv-keys 6BF18B15 sudo gpg --armor --export 6BF18B15 | sudo apt-key add -
Now you can update apt-get’s list of available packages to take the new repository into account and install BitTorrent Sync the same as any other software package in this series.
sudo apt-get update sudo apt-get install btsync
Unlike a lot of the installers you’ve encountered so far in this series, this one’s pretty chatty. It will ask you a lot of questions about how to set up the BitTorrent Sync daemon. All of the questions have reasonable default values suggested.
I won’t show a screenshot of all the questions, but simply suggest that you take all of the defaults, with the exception of assigning a password for the web administration interface.
If you understand what the settings mean, and know what you’re doing, you are welcome to tweak away to your heart’s content. You can always run the configuration tool again with the command “dpkg-reconfigure btsync”, although the questions may be a bit more extensive the next time around.
That’s it, BitTorrent Sync is installed. You’re ready to go. You can check on the status of the service like any other daemon.
sudo service btsync status
Create a sync folder
Unlike products such as Microsoft’s OneDrive, you don’t get just one sync folder. You can have as many as you want. Each one is created by either knowing or generating a secret, and associating it with a folder on your filesystem. Secrets are how BitTorrent works. In order for your computers to find each other, there is still a kind of central directory which generates the secrets, keeps track of which computers are online sharing that folder, and tells them all how to contact each other.
I’ve created a “Sync” folder in the root of my data partition on the hard drive I added in Part 6 of this series. This is the folder of stuff I want everywhere, all the time, such as my KeePass database file.
Sharing the Sync folder
Open a browser to your Raspberry Pi’s IP address, port 8888. This will bring you to BitTorrent Sync’s web interface. It doesn’t look like much, but that’s because you haven’t told it to sync anything yet.
Click the “Add Folder” button. You’ll see a dialog like this:
Click the “Generate” button to create a new secret. Each Secret is unique, and you’ll actually get two of them; a full-access secret, and a read-only secret. Write the secret down somewhere, or save it in a file. You’ll need it later in order to sync the folder with other computers.
Use the folder view at the bottom to browse to /mnt/data/Sync, or whatever you decided to use, and then click “Add”. You’ll return to the list of synchronized folders, but now your sync folder has been added.
BitTorrent Sync clients exist for Windows, Mac, Linux (obviously), and all major mobile platforms. Instructions for installing and configuring the clients will vary by platform, so I won’t cover that here. Whatever platform you’re on, install the client accordingly, and then use the secret you generated above to start syncing the files in that folder with the devices you choose.
Unlike other “cloud sync” technologies, you own the cloud in this case, and you can do pretty much whatever you want with it. There are no size limits other than your available storage, and you can create as many individual shares as you want. Because of the granular way in which BitTorrent Sync shares your stuff between computers, you can choose to share individual folders with friends and family, and control whether they get full control, or read-only access.
BitTorrent Sync gives you total control of your own private cloud.