Setting up BTSync on Ubuntu Desktop

When you install BTSync from the Ubuntu repositories it currently is set up as a service assuming you're running a server. This is generally a good thing, from a security standpoint, as it is set up with a new user account to keep BTSync permissions isolated from other users.

However, BTSync running as a service with a separate user account can be a little bit of a pain if you want BTSync to share out folders from your /home/{username} directory. This is an issue because your home directory folders are set to only be accessible by your user account, not by BTSync's service account.

The below steps walk through how to change the BTSync configuration to be used on a Ubuntu Desktop and run under your user account so BTSync can sync your home directory documents.

Correcting The BTSync Configuration

We'll need to stop any running BTSync services and stop the current service from auto running.

sudo service btsync stop
killall btsync
sudo rm /etc/init.d/btsync

Then we'll need to backup and copy the current config files to our home directory, along with setting up some new folder paths.

mkdir ~/.btsync
mkdir ~/.btsync/storage_path

cp /etc/btsync/user_config.json ~/.btsync/user_config.json
sudo mv /etc/btsync/user_config.json /etc/btsync/user_config.json.backup

cp /var/run/btsync/btsync.pid ~/.btsync/btsync.pid
sudo mv /var/run/btsync/btsync.pid /var/run/btsync/btsync.pid.backup

Now we'll need to edit our config file, I've used vim in the example below, however you can use whichever text editor you're comfortable with.

vi ~/.btsync/user_config.json

Now we'll need to update the config file so BTSync uses are home directory paths. This basically tells BTSync to use our new config and pid files when it starts up. In the below config you could also changing the listening port in the section "127.0.0.1:8888".

Additionally, you'll notice that BTSync is bound to the loopback interface 127.0.0.1, this means that you have to be on the local machine to access the BTSync interface. If you want to make BTSync accessible to anyone on your network (which I do not recommend), you'd have to change the line to be "0.0.0.0:8888".

{
 "listening_port" : 0,
 "storage_path" : "/home/{username}/.btsync/storage_path",
 "pid_file" : "/home/{username}/.btsync/btsync.pid",
 "agree_to_EULA": "yes",

 "webui" :
  {
   "listen" : "127.0.0.1:8888"
  }
}

It's time see if we've configured everything correctly, run the below command to start our new configuration of BTsync.

/usr/bin/btsync --config /home/{username}/.btsync/user_config.json

If everything runs correctly you'll see something similar to the below.

By using this application, you agree to our Privacy Policy, Terms of Use and End User License Agreement.
https://www.getsync.com/legal/privacy
https://www.getsync.com/legal/terms-of-use
https://www.getsync.com/legal/eula

Webui is listening on 127.0.0.1:8888
BitTorrent Sync forked to background. pid = {pid_num}

If you see this message you've configured everything correctly. From here you should be able to browse to https://127.0.0.1:8888/gui/ and see the BTSync web GUI.

Make sure you add the below command to your login script for your user profile so BTSync starts as you login. As a recommendation I put a 10 second delay on the start up so it doesn't bog down your login.

/usr/bin/btsync --config /home/{username}/.btsync/user_config.json

Common Errors

Some of the common errors I've seen are:

 Can't lock pid file. It seems BitTorrent Sync is already running with pid {pid_num}

The error above occurs if you still have an instance of BTSync running. Make sure you've run the killall bysync command above.

The other common error is:

Can't parse config file "/home/{username}/.btsync/user_config.json": "Storage path specified in config file does not exist."

Storage path specified in config file does not exist.

The above error occurs when the paths in the user_config.json file are not referenced correctly, or your local user account cannot access the file paths. Go back and check you've put the full path for the files in the user_config.json file and the permissions on those paths are correct.

References

Below are sites that I originally referenced as part of pulling this post together.


Updates

BTSync has since changed its name to Resilio, however given that all the config files still refer to BTSync I'm sticking with the original name.*