安装

直接从官网下载相应的安装包,为了在Linux服务器上安装,使用的是Linux x64版本BitTorrent-Sync_x64.tar.gz

然后解压到指定的文件夹,即可执行程序。


sudo mkdir -p /usr/local/btsync
sudo chown shenfeng /usr/local/btsync
tar -zxvf BitTorrent-Sync_x64.tar.gz -C /usr/local/btsync/

进入解压后的目录,可以看到3个文件,其中btsync为可执行文件。


$ ls
btsync LICENSE.TXT README

执行--help可以查看帮助信息


./btsync --help BitTorrent Sync 2.3 (239)
Usage:
btsync [ options ... ]
Options:
--help Print this message
--config Use a configuration file
--storage Storage path for identity and license
--identity Creates user identity
--license Apply owner license
--nodaemon Do not daemonize
--dump-sample-config Print a sample configuration file
--log Set log file
--webui.listen : Set the webui listening interface
--generate-secret Generate a read/write key
--get-ro-secret Get the read-only key associated to a read/write key

配置

编写启动脚本。


$ sudo vi /etc/init.d/btsync
#!/bin/sh
#
# description: starts and stops the btsync client CONF=/usr/local/btsync/btsync.cfg
PROC=/usr/local/btsync/btsync
PIDFILE=/usr/local/btsync/btsync.pid start() {
PID1=$(pidof btsync)
if [ -z ${PID1} ]; then
echo -n "Starting BitTorrent Sync: "
${PROC} --config ${CONF}
else
echo "BitTorrent Sync is already running at pid:${PID1}"
fi
return $?
} stop() {
echo -n "Stopping BitTorrent Sync: "
PID1=$(pidof btsync)
if [ ! -z ${PID1} ]; then
kill -9 ${PID1}
echo "OK"
else
echo "Failed"
fi
return $?
} status() {
PID1=$(pidof btsync)
PID2=$(cat ${PIDFILE})
echo -n "Checking BitTorrent Sync: "
if [ ! -z ${PID1} ] && [ "${PID1}" -eq "${PID2}" ]; then
echo "OK"
else
echo "Failed"
fi
return $?
} case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 1
start
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 2
esac

编写启动配置文件


{
"device_name": "vm_2",
"listening_port" : 8889, // 0 - randomize port "check_for_updates" : false,
"use_upnp" : false, "storage_path" : "/usr/local/btsync",
"pid_file" : "/usr/local/btsync/btsync.pid", "download_limit" : 0, // 0 - no limit
"upload_limit" : 0, "webui" :
{
"listen" : "0.0.0.0:8888",
"login" : "admin",
"password" : "btsync"
} ,
"folder_rescan_interval" : 1,
"lan_encrypt_data" : false,
}

启动程序,通过web页面进行登录和后续配置。


$ /etc/init.d/btsync start
Starting BitTorrent Sync: 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 0.0.0.0:8888
BitTorrent Sync forked to background. pid = 15002

在浏览器页面登录控制页面,即服务器IP+8888端口。

使用配置文件中的账号密码进行登录。

使用BitTorrent-Sync实现双机文件双向同步-LMLPHP

在启动一台主机上,点击左上角的Add Folder按钮,增加需要同步的目录。

使用BitTorrent-Sync实现双机文件双向同步-LMLPHP

确认打开目录后,会生成该目录的Key,因为需要双向同步,那么选择READ+WRITE的Key。

使用BitTorrent-Sync实现双机文件双向同步-LMLPHP

登录第二台服务器,登录后,点击Add Folder的第三个选项。填入上面复制的Key之后,选择本地用于同步的目录就可以进行同步了。

使用BitTorrent-Sync实现双机文件双向同步-LMLPHP

使用BitTorrent-Sync实现双机文件双向同步-LMLPHP

参考文档

05-11 15:19
查看更多