Introduction: Using BitTorrent Sync to Synchronize Your Files
Let’s say you want to have quick file sharing between your office computer and your personal laptop, but you have some concerns about cloud-sharing systems. Maybe your file size needs require flexibility that a lengthy subscription doesn’t afford, or you’re worried about the constant full file uploading stretching your bandwidth. This is where BitTorrent Sync comes in. Sync allows peer-to-peer synchronization between multiple devices, such as different computers, phones, and tablets. Updates are sent directly between the connected devices, only uploading what has been changed and with no lag connecting to a cloud server.
BitTorrent Sync has many advantages over other conventional file-sharing services. There is no concern about overages in bandwidth or file size like there is with cloud-based services such as Google Drive and Dropbox, and the service does not rely on overly-aggressive ads like the web-based Mediafire. This makes it an advantageous service to use for files that are large and would be expensive to host, such as movies and multimedia projects. As a program reliant on peer-to-peer networking, the files you share stay in your control, protecting your privacy. All you need for this tutorial is two computers or devices you would like to connect, and a local area network or access to the Internet.
This tutorial has five steps:
- Configuration and Usage
- Solving Conflicts
- Ignoring Files (This step is optional and probably only needed by advanced users)
- Installing into Raspberry PI (This step is optional and probably only needed by advanced users)
Step 1: Installation
1. First, visit the website for BitTorrent
Sync and use the free download to get the correct versions for the devices you’d like to use. Sync features versions for Windows, Mac, Linux, Android, iOS, and Kindle; as well as support for custom systems and dedicated servers.
2. Download the installer for your selected version
3. Confirm the dialogs that your browser will ask, and run it the program start the setup process
4. Choose an installation path, as well as the options you prefer. It is recommended that you create a desktop icon for ease of access, and a firewall exception so the program can access your network easily
5. Finish the installation process, then read and agree to the User Agreement
6. Tell the program if this is the first device you’re installing it on. If this is your second device, you can link to your first device right away by scanning a QR code or pasting in a keycode.
7. Enter the username for your computer, and you will be on the main screen for Sync and ready to begin!
Step 2: Configuration and Usage
Configuration is very simple through the dialogue box from clicking on the cogwheel (). From here you are able to see and connect devices or create a manual connection to another device, but you will need a means to connect from the other device if using manual. With preferences, you are able to see the settings in order to configure your sync to fit you.
General settings allows for changing if sync will start when your computer starts up, the default folder location for syncing and which columns will show up on the main page such as progress, size and the date it was synced.
1. To begin syncing, you will of course need two devices.
2. Click on the button on the right side of the folder you have selected to be the shared section.
3. You can pair devices with a number of ways, through email, or using a passcode or QR code provided.
4. Select a folder to sync between devices.
5. Drag items in the folder of the original device.
6. Sync the folder to the new device to the selected location.
7. You can also modify the permissions to allow the folder and files to be read only or give the other device to read and write over any files that are shared.
Step 3: Solving Conflicts
First and foremost, we must understand what conflicts are and how they occur. A conflict is a file that has been modified on Computer A and on Computer B at the same time, thus, when BitTorrent Sync tries to synchronize the file it gets confused because both files are new. Which file should it synchronize first? And what happens if the file in Computer A modified a line that user from Computer B did not expect to go missing? No software is smart enough to know what to in this scenario, thus, human interaction is required at this point to decide how to deal with the situation.
Notice how conflicting files only happen when we modify the same file in two machines or more before allowing the file to synchronize. Keeping that in mind, the best way to prevent conflicting files is to synchronize the files as soon as we can and, most importantly, not working on the same file on more than one machine at a time. Let us reiterate, the best way to avoid conflicting files is to not edit the same file on two or more computers. BitTorrent Sync is not an online collaborative file editing utility. Follow this advice and you will not have to deal with conflicting files.
However, if for some reason you do end up with conflicting files these are the things that you need to know:
- All conflicting files can be located in .sync/Archive
- .sync/Archive also stores the files that have been deleted
- By default BitTorrent Sync keeps files in .sync/Archive for 30 days before irreversibly deleting them
- Conflicting files are most commonly known as “versioned” files
- Older versions of the files are marked by adding numbers to its name, where the number with the highest number is the latest file.
- sync_trash_ttl is the setting that by default leaves files for 30 days. If set to zero, all files will be automatically deleted and not kept in .sync/Archive
Lastly, let us consider an example to demonstrate which steps must be followed:
1. Identify the conflicting file. Let us suppose that the filename is notes.txt
2. Browse to the directory .sync/Archive. Remember that the .sync folder is always located on the folder that you shared in BitTorrent Sync.
3. Look for file named notes.txt. There may be more than one file with this name, if that is the case this simply means that there are several versions of the same file. Look for the file with the highest number on its name, this signifies that it is the most recent version of the file. For example, notes.3.txt
4. Compare notes.txt with notes.3.txt and resolve the file differences. See if there is anything that is not notes.3.txt that you would like to add back to notes.txt. This is the most difficult step and the step that requires human interaction. Only you can decide, after comparing both files, how to solve the conflicts in the file.
Step 4: Ignoring Files (This Step Is Optional and Probably Only Needed by Advanced Users)
BitTorrent Sync offers greater flexibility than Dropbox in terms of which files to synchronize. With Dropbox, you can only synchronize one folder (generally called Dropbox). However, with BitTorrent Sync you can synchronize as many folders as you desire. With this greater flexibility we may run into scenarios where we wished BitTorrent Sync did not synchronize some files or folders. Needless to say, BitTorrent Sync does provide the tools to deal with this situation: the special file .sync/IgnoreList. Before we can start making use of the IgnoreList file we must know two wildcards; a wildcard character is a special character that represents one or more other characters.
- The “*” wildcard character. It is a substitute for a single character instance.
- The “?” wildcard character. It is a substitute for multiple character instances.
Now, let us examine four examples (courtesy of the BitTorrent Sync unofficial FAQ)
1. *.dat – This will match all files that have the .dat extension, regardless of where the files are located
2. abc???.dat – This will match abc123.dat, abcqwe.dat, abc948.dat, etcetera. However, it will not match abc1234.dat.
3. *.mp? – This will match any mp3, or mp4 files. However, it will not match mpeg files.
4. /*.avi – This will match any avi files that reside in the parent directory. It does not match avi files located in subdirectories.
A common mistake is to try to add several files to ignore in one line. It must be noted that in the IgnoreList file you can only have one file to ignore per line, as we can observe in the following IgnoreList file sample:
Each line can represent a file and/or a directory. For example, if we had the line MyTest in IgnoreList BitTorrent Sync would ignore all files with the name MyTest, as well as all directories called MyTest. Notice gpg/keys in the previous example, this means ignore the file keys that is located inside the folder gpg. The forward slash is called a delimiter and it separates 2 or more components; it is worthwhile to notice that Linux and OSX systems use a forward slash while Windows uses a backwards slash for the delimiter.
Lastly, keep in mind that IgnoreList is applied only to the directory where it is contained and it will not work with the files that have already been synced. If you add an indexed file in IgnoreList it delete the indexed file from other syncing devices.
Step 5: Installing Into Raspberry PI (This Step Is Optional and Probably Only Needed by Advanced Users)
Disclaimer: This section requires a basic level of
proficiency with the Raspberry PI and assumes the reader knows how to set a Raspberry PI and how to get terminal access to it.
One very big difference between BitTorrent Sync and Dropbox is that your files are not stored on a server owned by a company. This difference means that your files are more secure as opposed to Dropbox, especially since Dropbox does not even encrypt your files. However, this security feature of BitTorrent Sync may also be an inconvenience, since you would need to keep one of your computers always turned on if you want to be able to synchronize files at all times. Here is where the Raspberry PI model B+ comes to the rescue, it can run BitTorrent Sync all day. Furthermore, keeping the Raspberry PI model B+ turned on at all times should not affect your electricity bill very much since it only uses around 1.2 watts an hour.
To install BitTorrent Sync in the Raspberry PI we simply need to open a terminal on the Raspberry PI and run the following commands:
1. mkdir btsync && cd btsync
2. curl “https://download-cdn.getsyncapp.com/stable/linux-arm-BitTorrent-Sync_arm.tar.gz” > btsync.tar.gz
3. tar xf btsync.tar.gz
Just to make things more clear, and to show you what to expect here is a screenshot where I have written the previously mentioned commands (the ls command is not necessary and I included it only to show you which files you should expect):
Note: The URL from the picture above should not change, but if step 2 fails for you, then the reason is that the URL changed. In that case just obtain the new URL by executing the following command:
Now BitTorrent Sync should be running on your Raspberry PI and it can be configured by going to a web browser on your computer and typing the IP address of your Raspberry PI (let us assume in this case that it the IP is 192.168.1.2). E.g. http://192.168.1.2:8888
Keep in mind that the port for the URL will always be 8888, unless you change it, as 8888 is the standard port that BitTorrent Sync uses.
This website is where you configure your shared folders. Just click on “Add Folder” and follow the instructions. Lastly, if you are well-versed in Linux you might have noticed that step 4 runs the BitTorrent Sync client, but this means that if we restart the Raspberry PI we would need to run this command every single time. The solution is to automatically run the BitTorrent Sync after each restart. We accomplish this by following these steps:
1. Create a systemd unit file. This instructs systemd (the software in charge, on Linux, of executing programs upon boot)
2. Save the unit file in ~/.config/systemd/btsync.service
3. Enable the unit file by writing: systemctl --user enable btsync.service
We have a be nice policy.
Please be positive and constructive.