Raspberry Pi Home Server: Part 14, BitTorrent Sync

Article Obsolete

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:
(http://www.pluralsight.com/courses/raspberry-pi-home-server)
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.

image

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.

mkdir /mnt/data/Sync

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.

image

Click the “Add Folder” button. You’ll see a dialog like this:

image

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.

Other computers

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.

Wrapping up

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.

This entry was posted in Computers and Internet, Home Server, Raspberry Pi and tagged . Bookmark the permalink.

52 Responses to Raspberry Pi Home Server: Part 14, BitTorrent Sync

  1. sinouhe says:

    Your serie is absolutely great !
    A must. Thank you
    Hope it continues…

  2. ylau1970 says:

    Great instructions.
    Would you consider doing a tutorial on adding CUPS and a WIFI dongle to make a wireless printer driver?

    • Mel Grubb says:

      The WiFi dongle is something I’ve done, but didn’t post about because the instructions can vary a lot depending on which brand you buy. I might do a post about it, though, since there is interest. I hadn’t done anything with printers because my own home server lives on a rafter in the basement, next to the router. I’ll put it on the list of things to get to, and see what I can come up with.

  3. wes says:

    i followed your directions, but was presented with a login screen. what is the default login?

    • Mel Grubb says:

      I’ll have to double check, but I think the first time you run it, you have to establish your account. Unfortunately, since I’ve already passed this step, I don’t think I get another shot at it unless I rebuild the whole thing. I’m at work, anyway, so I can’t see it until later tonight.

    • Sinouhe says:

      Uninstall:
      sudo apt-get –purge remove btsync

      Reinstall and reboot.
      You’ll be ask for a new login/password

    • Hello wes, I noticed the same thing, but it was actually a screen to create a login for the web interface, right?
      Maybe its new, on the version 2.0.

  4. Спасибо! ВЫ очень помогли мне!

  5. Pingback: BTSync WUI not working on Raspberry – blank page | DL-UAT

  6. Alan Cai says:

    I have a situation that, BT SYNC si running. but it cannot write to my usb driver. I cannot create folder in file manager either. It turns out that I can only do it by using “sudo mkdir” in terminal. My guess is that somehow I btsync codes not have the root permission. The file system is ext 4. how can I solve this problem?

    • Mel Grubb says:

      Since I set mine up as NTFS, I sidestepped the whole Linux permissions problem. You can either open up write permissions to everyone (chmod 755), or more selectively to just the BTSync user. There are a ton of tutorials out there that will do a better job of explaining Linux file permissions than I can do here in a comment. Start with http://en.wikipedia.org/wiki/chmod

      • Alan Cai says:

        ok. I format the drive into NTFS. now, I can create folder in file manager. But then, btsync still have problem. It can find the external driver under “media”. but it cannot read the folders inside the driver. When I ask bt sync to create a folder, it still cannot do it. Please help. Thanks

      • Mel Grubb says:

        If you’re not following the series as written, then you’ll have to adapt a bit. You may still need to set up the permissions with Chmod. chmod 755 at the directory level should do the trick.

  7. I am totally blown away by your series on the Pi. It is excellent! Kudos! Huzzah!!

    I’ll be using your tutorial to do just about everything in there. I’m an old geek, having used computers since 1983 (first PC was an IBM PC with cassette Basic as the OS). This series of articles, along with the latest Raspberry Pi, has tweaked my interest. I’ve been doing a lot of web sites lately (including WordPress sites; see list at http://www.cellarweb.com), but your series has really tweaked my interests into getting into the Pi world. Heading out to the garage now to gather up parts to go with my order of a new Pi.

    I am strongly hoping that you will write more of this stuff. Thanks for all of your efforts in writing all of this in a clear and concise manner. Please do not stop !!

  8. Pingback: Raspberry Pi Home Server: Index | MelGrubb.ToBlog()

  9. Altug says:

    Hi Mel,
    BTSync 2.0 is out, can it be installed onto the RPI?

    • Mel Grubb says:

      ________________________________

    • Mel Grubb says:

      I haven’t tried it myself yet, but as long as there’s an apt-get package with the new bits, I expect it should work the same. If there’s no new apt-get package, then we’ll have to wait for it to be updated. I hope to run through a whole build again this weekend to make sure the instructions are still current. ________________________________

  10. Altug says:

    The apt-get package has been updated, its now 2.0!!!

  11. Joshua Leasure says:

    This is a great series of posts! Thanks for doing this.

    I installed btsync according to your directions and it appeared to be working great. The Pi ran all night but btsync did not. ‘service btsync status’ reports:

    [FAIL] BTSYNC ‘debconf-default’ is not running … failed!

    Searching on this error hasn’t found anything for me. I’ve been looking for a btsync log file for clues but either there isn’t one or I just can’t find it.

    Any ideas? Either on what could be happening or where I can find a log file (or how I can create one)?

    • Mel Grubb says:

      That’s certainly not something I’ve seen, and in fact it appears that even Google only knows of three pages mentioning that error. Whatever it is, it’s not common. I just set up BTSync again on a Pi a couple weeks ago, so I don’t think they’ve broken anything in the installer unless it’s very recent. If that’s the case, then I expect I’ll be getting more comments along the same lines as yours. I may also be doing another rebuild in the near future, so I’ll be sure to check it then. In the meantime, I hope you find something, and please reply here, and maybe Google will pick it up for the next guy. Also, I’d recommend self-answering a question on the Raspberry Pi Stack Exchange site.

      • Javier says:

        I have the same problem here! I installed it just as said (presumably) and it just sais “[FAIL] Failed to stop btsync instance debconf-default … failed!” I’ve tried rebooting, force-reload and everything but nothing seems to work, i’ll try re-installing and see if that helps. Amazing work you did, Thanks a lot even though i haven’t been able to get it running 🙂

        (Sorry if bad english)

      • Javier says:

        Reinstalled and works fine, I should have tried before posting… sorry…

      • Mel Grubb says:

        I’m glad it worked out. I worry a little every time someone has a problem. I had to rewrite the crash plan part because they put out a new version and the instructions didn’t work anyone. Fortunately it was still possible to install, and was actually easier after the change.

    • Ben says:

      I just had this problem and found the solution. Hopefully saves someone else’s time.

      My problem was I was trying to get the btsync user to read data from /media/ben/EXTDRIVE. Remounting the drive in /mnt/EXTDRIVE fixed the problem (and getting btsync reconfigured to the new directory). Then I just set up a symbolic link for backwards compatibility.

  12. Hello! I’m having an issue. I installed it and followed your guide to the letter, but I can’t write to the USB drive! I loaded it up and now it says “You do not have permission to write to this directory.” I’m on a Raspberry Pi and I’m writing to write to a USB stick. Any suggestions? I went in and did a “sudo chmod 777 *” but that didn’t help.

    When I telnet in, I have access to the directory and I can make files in it… When I did the the configuration I told it that it’s directory should be /media/128GB, as that’s what it’s called. I checked the /dev/ folder and I only have “sda” and not “sda” and another “sda1” and I really don’t know how to follow :s

    Any ideas anyone? Thanks.

    • Mel Grubb says:

      Usually, going through Webmin takes care of it all for you, but this step seems to cause a lot of people problems, so let’s take a look at things directly from the command line. There are two places where permissions come into play. There are the permissions on the “mount point” (e.g. /mnt/external), which you should set to 777. Then, there are the permissions that Samba imposes, for which you’ll need to look at the Samba config file (/etc/samba/smb.conf). Find the section that Webmin added for the share, which should be at the bottom. Tweak it to look like this, substituting names and paths as appropriate.

      [External]
      comment = Raspberry Pi NAS
      path = /mnt/external
      browseable = yes
      writeable = yes
      only guest = no
      create mask = 0777
      directory mask = 0777
      public = yes

      Restart Samba, or just reboot the whole thing, and see if that makes a difference.

      • Thank you very much for your reply! I’ve encountered a completely different error now. But before that, I’d like to explain what I’ve done. It seems that the permission was wrong, so I was trying to play around with it a lot. It seems like your idea would have worked, but what I ended up doing was formatting the whole darn drive in ext4 format. It worked right off the bat. Now, I have a new issue! I have 55gb of data, and the darn RPi is so slow to copy that I copied it onto a flash drive and plugged it in (which appears) but it won’t let me copy it to the folder inside the 128gb drive (the now ext4). I keep getting permission denied.

        If I go through command prompt and “sudo bash”, then I can edit, manipulate, and everything. But what I’d like to do is copy recursively the content of one drive to another. I can’t seem to get the code right. What WOULD be best would be able to just use the GUI and copy and paste. This helps me a lot when I need a .syncArchive file or something like that. I tried going to “Tools” and then “Open current folder as root” but I get “Failed to execute child process “gksu” (no such file or directory).”

        Is there something I can do? When I check on the permissions, it’s bound to btsync as owner and group. Access control is is owner = read write, and group and other = read only. I tried to change the “other” to read write as well to temporarily copy everything, but it gave me errors. I tried to remote desktop in as “btsync”, but I have no idea what the password would be… I also tried chmod 777 /media/128USB/ as sudo bash to try and get in there and delete, copy or open a file; but I’m constantly greeted by the ever-so-charming “permission denied” message.

        Any thoughts? Thank you very much!

      • Mel Grubb says:

        I completely misread the original question. I thought you were asking about permissions with the Samba shares. I was dealing with permissions on those yesterday, and it was still in my head. BTSync is a whole different problem, I guess. I would still think setting permissions on the mount point to 777 would eliminate permissions-based issues. When I installed BTSync, I didn’t run into any permission issues. Then again, I used an NTFS drive which sidesteps a lot of Linux security issues by its very nature. I’ll have to try setting up BTSync against an ext4 filesystem and see what happens. It probably won’t be this weekend, though. I’ll add it to the list of things to investigate, though.

      • Haha, I hear you! I guess I’ll just reformat the drive with NTFS and try again with your instructions from your previous comment. Any good tutorials on how to format in NTFS and have the file system work with BTSync? 🙂 I’m not really good at this kind of stuff. :$

  13. Pingback: Meine eigene kleine Dropbox | Eine digitale Welt

  14. Spacemap says:

    Nice tutorial…but why don’t you use syncthing? Its free…even open source and hasn’t got the regulations of BTsync…
    “To ensure everyone has the ability to sync and share directly, without the barriers of the cloud, the core Sync functionality is free. Free users have the ability to synchronize up to 10 folders…” [1]

    [1] http://blog.bittorrent.com/2015/03/03/sync-2-0-skip-the-cloud-share-direct/

  15. Zisiki says:

    Mel, to begin with I’m totally new to linux. Whenever I do anything with linux I follow tutorials step by step.
    I did every step as you wrote in the article, and kept running into this:

    chmod: changing permissions of `/mnt’: Read-only file system
    dpkg: error processing btsync (–configure):
    subprocess installed post-installation script returned error exit status 1
    Errors were encountered while processing:
    btsync
    E: Sub-process /usr/bin/dpkg returned an error code (1)

    I wonder what is wrong…

    • Zisiki says:

      Sorry to bother everyone. I turned out that I mounted my NTFS disk the wrong way. I installed NTFS-3G and mounted it again everything worked! Thanks, Mel!

  16. James M says:

    Why is it, that my raspberry pi after I run apt-get update / upgrade / dist-upgrade does’nt update btsync from version 2.0.93 to one in the 2.1.* array or the newest 2.2.0?

    • Mel Grubb says:

      What’s in the repositories isn’t always up to date. Also, at present, the most up-to-date version of Raspbian is Wheezy, while the rest of the Debian world has moved on to Jessie. It’s possible that the Jessie repositories would have a more current btsync. You could change “wheezy” to “jessie” in your .list file, and re-install btsync to see what would happen, but I haven’t tried that yet myself. I have updated MiniDLNA to a later version this way, but not btsync. I got it up and working, and that was good enough for me. I figure that when Raspbian moves to Jessie I’ll have to re-evaluate this whole series and make sure it all still works anyway. Until then, my cloud is working, and my stuff is syncing, so I’m okay for now.

  17. Ted says:

    Everything went OK until I issued: sudo apt-get install btsync
    It says “unable to located package”…what’s wrong?

  18. Ted says:

    Never mind! the “btsync.list was in the WRONG place.

  19. Ted says:

    OK, now I have a real issue:
    1) I DID NOT want a Pro account, but I ended up with one.
    2) I NEVER asked me to generate a ‘Secret Code’

    HELP!

  20. Ted says:

    Never mind AGAIN! All is well 😀

  21. scottvoyles says:

    I had a problem with package authentication and found this excellent script directly off Yeasoft’s website. Not so great for educational purposes, but it does the trick!!

    sh -c “$(curl -fsSL http://debian.yeasoft.net/add-btsync-repository.sh)”

    [1] http://www.yeasoft.com/site/projects:btsync-deb:btsync-repo

  22. Pingback: Hemmaserver på Raspberry Pi | madmax4ftw

  23. Hey there, I think your website might be having browser compatibility issues.
    When I look at your blog site in Ie, it looks fine but when opening
    in Internet Explorer, it has some overlapping. I just wanted to give
    you a quick heads up! Other then that, very good blog!

  24. Pingback: Configuring Your New Raspberry Pi (As a Server)

  25. DanL says:

    Where do we look for the license.bin file? I just want to make sure it isn’t there. Thanks!

    Dan

    • Mel Grubb says:

      Sorry it took a bit to get to my comments. I know the license file moved with more recent installations, but you should be able to find it with something like

      find / -name “license.bin”

      This will search everything for the root down for a file with that name. Now, make sure that you only delete things that belong to BtSync, judging by the file’s complete path. I’m sure there’s something else out there that decided to use that same filename.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s