rsync 同步

两台android 设备 进行rsync 同步

1。编译 rsync 源码

sudo apt-get install gcc-arm-linux-gnueabi

wget http://rsync.samba.org/ftp/rsync/rsync-3.1.0.tar.gz
tar -zxv -f rsync-3.1.0.tar.gz
cd rsync-3.1.0

./configure --host=arm-linux-gnueabi CFLAGS="-static"
make

2. 将生成的rsync 复制到/system/xin下  这个可以根据需求 到不同的目录下。

 

配置文件 rsyncd.conf
# Distributed under the terms ofthe GNU General Public License v2
# Minimal configuration file for rsyncdaemon
# See rsync(1) and rsyncd.conf(5) man pagesfor help
# This line is required by the/etc/init.d/rsyncd script
pid file = /data/shareData/rsyncd.pid
port = 55873
uid = 0
gid = 0
secrets file = /etc/rsyncd/rsyncd.secrets
hosts allow = *
use chroot = yes
read only = no
max connections = 5
#This will give you a separate log file
log file = /data/shareData/rsync.log
log format = %t %a %m %f %b
syslog facility = local3
timeout = 300
[test]
path = /data/shareData
lock file = rsyncd.lock
#list=yes
hosts allow = *
ignore errors
secrets file = /etc/rsyncd/rsyncd.secrets
auth users = root

 

密码文件  rsyncd.secrets

root:root

密码文件  rsyncd.secrets2

root


以上三个文件都要自己建立 然后复制到/etc 下面 (不同的情况需求放在不同下面)

可能有时候调试回报错因为文件的权限不对,或者不同机子的设置不同 这个遇见问题google好了

 

运行
启动服务
/system/xbin/rsync --daemon --config=/etc/rsyncd/rsyncd.conf

同步文件

/system/xbin/rsync -avzP --timeout=30 --delete --password-file=/etc/rsyncd/rsyncd.secrets2 root@192.168.84.215::test/rsync/ /mnt/sdcard/


上面的意思是将远端192.168 目录下的/rsync文件的内容 同步到本机 sdcard

以上命令直接可以在 命令行运行

如果要用代码运行在java中 Runtime.getRuntime().exec 相关命令


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值