Skip to main content

How to Use BitTorrent Sync to Backup Linux Server

Backup Linux Server

This tutorial explains how to install and use BitTorrent Sync to automatically backup Linux server. BitTorrent Sync allows you to sync folders between machines using BitTorrent protocol. You can sync folders between your computer and smartphone directly. There’s no need to upload content to third-party servers. Contents transmitted by BitTorrent Sync are protected with 256bit AES Encryption.

Because it uses BitTorrent protocol, there must be at least two machines online in order to sync folders. You probably won’t keep your personal computer online all the time. But server is another story. Servers are running almost all the time and connected to the Internet. So using BitTorrent Sync to backup your Linux server is a very good idea.

Sync Scenarios

  1. You have two Linux servers that are running and connected to the Internet 24 x 7,  then you can use BitTorrent Sync to automatically sync folders between them.
  2. You have just one Linux server. You can sync folders between your server and your home computer. When your home computer starts, it will automatically fetch new contents from your Linux server.
  3. You have a Raspberry Pi. You can keep your RPi up and running 24 hours a day and sync folders between your Linux server and RPi. After all, a Raspberry Pi consumes very little power and it does not cost you too much money.

So let’s get started.

Backup Linux Server with A Master Server and a Slave server Setup

If you have two servers then you can configure one as master and another as slave. That means, you update your website content on master server and the slave server can only read the syncing folder on master server but it can not add new content to the syncing folder. The slave server is used only for backup purpose.

Install BitTorrent Sync on Master Server

You can use the following method to install BitTorrent on any Linux distribution.

Log into your Linux server via SSH and download the Linux version of BitTorrent Sync.





Extract the tar file.

tar xvf BitTorrent-Sync_*.tar.gz

Now a new executable file named btsync will be extracted to the current working directory and it’s ready to run. You can start BitTorrent with the following command:


By default the WebUI is only accessible on the computer running Sync (localhost:8888). In order to have the WebUI accessible across the LAN or Internet, start Sync this way:

 ./btsync --webui.listen

Now you can access the WebUI by typing the following in your browser address bar. Replace your-server-ip with your actual server IP.


When you first access the WebUI, you will be asked to create an account. But we are using plain HTTP protocol right now and it’s unsafe. So before we create a username and password, we need to install a SSL certificate on the Linux Server. Read the following article to get a free SSL certificate from Let’s Encrypt.

An Overview of HTTPS Encryption and Let’s Encryption on Nginx Deployment

I will use as the domain name to access the WebUI. So I applied a SSL certificate for and you need to apply SSL certificate for Replace with your actuall domain name.

After you got a SSL certificate, come back here.

Setup Nginx Reverse Proxy

Now we will setup Nginx as a reverse proxy for the BitTorrent Sync service. In this setup, btsync only need to listen on the localhost (

Create a Nginx server block file.

sudo nano /etc/nginx/conf.d/

Paste the following text into the file.

server {
   listen 80;
   return 301$request_uri;
server {
   listen 443 ssl;

   ssl_protocols TLSv1.1 TLSv1.2;
   ssl_certificate /etc/letsencrypt/live/;
   ssl_certificate_key /etc/letsencrypt/live/;
   access_log /var/log/nginx/;
   location / {

save and close the file. This configuration will redirect all plain HTTP request to HTTPS and the server will only accept TLSv1.1 and TLSv1.2 encryption. When you type in the browser address bar, Nginx will pass the request to

Reload Nginx

sudo service nginx reload       or      sudo systemctl reload nginx

Now access Sync WebUI by going to Create a username and password to secure the WebUI.

Create a username and password to secure BitTorrent Sync WebUI

After you created an account and signed into WebUI. It’s time to add a folder on your master server for synchronization. But in order to add a folder on your server for syncing, the user running btsync process must have write permission to the folder which will be synced.

The user running btsync process is the user who invokes the btsync command.

Let’s say you want to sync the web root directory of your server such as /usr/share/nginx/ and this directory is owned by user www-data and group www-data. It’s permission is set as 755 so only www-data user have write permission.

drwxr-xr-x 7 www-data www-data 4096 Mar 9 21:58 nginx

In order to let user www-data and the user running btsync both have write permission, we can use setfacl command to grant write permissions to the user running btsync.

sudo setfacl -R -m "u:<username>:rwx" /usr/share/nginx

In this way, both www-data and the user have write permission to the web root directory. Now you can add the web root directory for syncing. btsync will generate a sharing link, secret key and QR code for this syncing folder.

add the web root directory for syncing

Setting Up the Slave Server

The process for the slave server is almost the same with master server. You install the btsync program, get another free SSL certificate from Let’s Encrypt and setup Nginx reverse proxy. Then create an account to secure the WebUI.

The only difference is that after you signed into the WebUI of the slave server, you need to click the arrow at the upper-left corner and select Enter a key or link from the drop-down menu.

BitTorrent Sync backup Linux Server

Then, go to the master server WebUI, click the share button, then copy the read only key and paste the read only key in the slave server WebUI.

BitTorrent Sync Secrect key

After that you need to select a directory on your slave sever to receive the files from master server. There are two keys. One is for read & write access, the other is for read only access. We copy the ready only key because we don’t want to let the slave server add new content to the syncing folder.

Now the two servers begin the syncing process.

Backup Linux Server with Your Home Computer

If you are using Linux as your home computer’s OS, then follow the above method to install BitTorrent Sync. After it’s installed, you can start btsync and begin syncing right away, you don’t have to setup Nginx reverse proxy and install SSL certificate on your home computer.

Backup Linux Server with Raspberry Pi

BitTorrent Sync has an ARM version, so you have to download the ARM installer for Raspberry Pi and then extract it.


If your Raspberry Pi is headless, then in order to have the WebUI accessible across the LAN or Internet, start Sync this way:

./btsync --webui.listen

Again, you don’t need to install SSL certificate on Raspberry Pi or setup Nginx reverse proxy.

Autostart on System Boot

To let BitTorrent Sync automatically start on system boot, add a cron job as a normal user.

crontab -e

add the following line at the end.

@reboot /path/to/btsync --webui.listen

Replace /path/to/btsync with the actual path. If btsync only need to listen on localhost( then remove the –webui.listen part.

So you see it’s easy to backup Linux server and Happy syncing!

Rate this tutorial
[Total: 0 Average: 0]