How to set up BitTorrent Sync on a Linux server to create a Dropbox-like syncing solution

Tutorial – How to set up BitTorrent Sync on a Linux server to create a Dropbox-like syncing solution

btsync_diagramBitTorrent Sync (BTSync) is a “Private Dropbox” of sorts in that it offers the same functionality (syncing your files across devices) but without going through a third-party’s servers. Mac and Windows clients are available for download and have some nifty features such as one-time share keys and read-only syncing options. The advantage of BTSync is better handling of large files (especially if you sync across multiple devices) and you don’t have your files hosted on someone else’s server(s).

The advantage of Dropbox is that should you lose all your machines that were syncing to Dropbox, you would still have a copy in the Cloud that you would be able to download on a new machine. This is undoubtedly BTSync’s biggest disadvantage if you don’t have at least two machines on all the time. If, however, you have a server, you can set up BTSync on that server thus creating your own “always-on” sync machine that will create a copy of the files you wish to sync immediately. Let’s get started…

Assumptions: This tutorial does not aim to teach you how to use the BTSync Mac/Windows clients. For the rest of the tutorial, I recommend creating a test folder on your computer, generating a BTSync key for that folder, and then adding that key to the new BTSync instance you’re about to create on your Linux-based server.

Requirements: This tutorial assumes you have a Linux-based server. It does not have to be a dedicated server but you do need to have enough rights to download and install stuff.

Step 1 – Download the right version

Download the Linux BTSync version that is appropriate for your server here. You’ll notice that there are several versions available:

BitTorrent Sync Linux Download Options

BitTorrent Sync Linux Download Options

If you’re not sure which one is for you, print out your system information using this command:

uname --all

or

uname -p to get your processor.

These commands will output something like:

Linux s123456789.domainepardefaut.fr 2.1.32-042stab076.5 #1 SMP Mon Mar 18 20:41:34 MSK 2013 x86_64 x86_64 x86_64 GNU/Linux

x86_64

For the above output, I downloaded the Linux_x64 version. From the server:

cd /tmp
mkdir btsync
cd btsync
wget http://btsync.s3-website-us-east-1.amazonaws.com/btsync_x64.tar.gz .

Step 2 – Install BitTorrent Sync

Ready? It’s as easy as 1-2-3:

tar -xvzf btsync_x64.tar.gz

This will extract btsync which is the executable. Since we’re still in /tmp, now’s a good time to move the btsync executable somewhere safer. I chose to create a folder at the root level “/BTSync”:

mkdir /BTSync
mv /tmp/btsync/btsync /BTSync

Note that by default, the files that will later be synced to your server will be located in a folder called .sync which will be located in the same folder where btsync runs. Later on, we’ll take a look at some configuration options that can help you modify this behavior.

You’re done. To start BTSync, run:

./btsync

At this point, you should be able to point your web browser to port 8888 on your server and you will see the BTSync GUI (http://youripaddress:8888).

btsyncgui

From here, you can easily sync folders with your server as you normally would by simply adding the shared secret keys that you have set up on your PC. The GUI is simple and easy to use. Though everything “just works” now, I did not want to keep the default port (8888) and password settings that come installed with the GUI. Let’s change that…

Step 3 – Set up a password, change the port (optional)

BTSync allows you to configure some settings, including a password to protect the GUI. To create a configuration file, create a btsync.conf file in the same folder where the btsync executable is located. In my example, that would be in /BTSync. If you want to get an example configuration file, you can execute:

./btsync --dump-sample-config

For convenience’s sake, I’ve made one available for download here.

To set a username/password, create or edit the config file, btsync.config and edit these lines with whatever values make sense for you:

“webui” :
{
“listen” : “0.0.0.0:8888“,
“login” : “YOUR_LOGIN_USERNAME“,
“password” : “YOUR_LOGIN_PASSWORD
}

Replace the bold values by whatever is convenient for you. When you’re done, you’ll need to restart the BTSync server and pass the configuration file as a parameter. To do so, kill the btsync process that you started earlier and restart it using ./btysnc --config btsync.config. To get the process ID, simply try to start the btsync process; if it is already running, it will print out its PID:

./btsync --config btsync.config
Can't lock pid file. It seems BitTorrent Sync is already running with pid 1857
kill -9 1857
./btsync --config btsync.config

BTSync Authentication

Now, when you close and re-open the GUI, you should get a password prompt.

For more information about BitTorrent Sync and the different configuration options available, visit the official website. To download BitTorrent Sync for Windows or OSX, click here.

Conclusion

I’m a big fan of DropBox and I’m happy to see similar services popping up. For most users, I’d say these services have an amazing offer, are easy to use, and are relatively cheap if not free – so if it works for you, stick to them! For power users, or for users who have lots of data they want to sync across several machines, BTSync provides a few advantages at the cost of some user friendliness (for now) and a more complex set up process. By setting up BTSync on a server with very high availability, you eliminate BTSync’s weakest point by allowing for a copy of your synced file(s) to be created almost immediately. You gain the privacy of your own server but you must also keep in mind that your sync capacity and reliability is entirely your responsibility. Finally, if you need to sync very large files, BTSync’s technology is the way to go. (You can read more about the technology used here.) At time of writing, it seems that mobile versions of BTSync are also being developed making BTSync a very powerful all-round syncing solution.

How to set up BitTorrent Sync on a Linux server to create a Dropbox-like syncing solution