GVKun编程网logo

zsync 基于HTTP的文件同步工具(http同步异步)

12

本篇文章给大家谈谈zsync基于HTTP的文件同步工具,以及http同步异步的知识点,同时本文还将给你拓展arRsyncMac文件同步工具、FishSync0.6发布,文件同步工具、FreeFileS

本篇文章给大家谈谈zsync 基于HTTP的文件同步工具,以及http同步异步的知识点,同时本文还将给你拓展arRsync Mac文件同步工具、Fish Sync 0.6 发布,文件同步工具、FreeFileSync – 免费开源的文件同步工具、linux文件同步工具- rsync等相关知识,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

zsync 基于HTTP的文件同步工具(http同步异步)

zsync 基于HTTP的文件同步工具(http同步异步)

zsync 介绍

zsync 是一个基于 HTTP
协议的文件同步(rsync)工具,通过它可以从远程的Web服务器上同步文件的改动。

zsync 官网

http://zsync.moria.org.uk/

arRsync Mac文件同步工具

arRsync Mac文件同步工具

arRsync 介绍

arRsync 是 Mac OS X 系统下的文件同步工具,是 rsync 工具的图形化界面。

arRsync 官网

http://arrsync.sourceforge.net/

Fish Sync 0.6 发布,文件同步工具

Fish Sync 0.6 发布,文件同步工具

Fish Sync 0.6 包含很多 bug 修复和小改进,首先更加灵活的查找运行时以来,支持大多数 Linux 和 BSD 系统;支持 MINIX;支持运行于非标准网络端口下的同步,更好的安全证书管理。

Fish Sync 是一个文件同步工具,可在多个机器间传输多个目录。该工具不需要在每台机器上都安装,只需要发起初始同步的机器上安装即可。

FreeFileSync – 免费开源的文件同步工具

FreeFileSync – 免费开源的文件同步工具

FreeFileSync 是款免费开源的文件同步工具,支持多种(双向/单项)同步方式,历史版本,定时自动监控等等.

FreeFileSync   免费开源的文件同步工具[图] | 小众软件

使用 FreeFileSync 也很容易,只需将要同步的文件夹放到 FreeFileSync 左右两侧窗口,设置同步类型,点击同步就可以了。更多细节等你自己挖掘.

这是下载地址 : http://sourceforge.net/projects/freefilesync/

linux文件同步工具- rsync

linux文件同步工具- rsync

rsync 文件同步工具

rsync命令是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件。rsync使用所谓的“rsync算法”来使本地和远程两个主机之间的文件达到同步,这个算法只传送两个文件的不同部分,而不是每次都整份传送,因此速度相当快。 rsync是一个功能非常强大的工具,其命令也有很多功能特色选项,我们下面就对它的选项一一进行分析说明。

格式

  • rsync [OPTION]... SRC DEST
  • rsync [OPTION]... SRC [USER@]host:DEST
  • rsync [OPTION]... [USER@]HOST:SRC DEST
  • rsync [OPTION]... [USER@]HOST::SRC DEST
  • rsync [OPTION]... SRC [USER@]HOST::DEST
  • rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]

选项

  • -a 包含-rtplgoD
  • -r 同步目录时要加上,类似cp时的-r选项
  • -v 同步时显示一些信息,让我们知道同步的过程
  • -l 保留软连接
  • -L 加上该选项后,同步软连接时会把源文件给同步
  • -p 保持文件的权限属性
  • -o 保持文件的属主
  • -g 保持文件的属组
  • -D 保持设备文件的信息
  • -t 保持文件的时间属性
  • --delete 删除SEDT中SRC没有的文件
  • --exclude过滤指定文件,如--exclude "logs"会把文件名包含logs的文件或者目录过滤掉,不同步
  • -P 显示同步过程,比如速率,比-v更加详细
  • -u 加上该选项后,如果DEST中的文件比SRC新,则不同步
  • -z 传输时压缩

举例说明

  • 创建目录test
  • 在目录test中创建文件1.txt>内容111,222,333、 软连接文件xuexi.sorft
[root@xuexi-001 ~]# mkdir test
[root@xuexi-001 test]# vi 1.txt 
[root@xuexi-001 test]# cat 1.txt 
111


222



333
[root@xuexi-001 test]# touch xuexi.txt 
[root@xuexi-001 test]# ln -s xuexi.txt xuexi.sorft
[root@xuexi-001 test]# ls
1.txt  xuexi.sorft  xuexi.txt
[root@xuexi-001 test]# echo "aaa" > xuexi.txt 
[root@xuexi-001 test]# cat xuexi.txt 
aaa
  • 将test目录 同步到/tmp/下并改名test2
[root@xuexi-001 test]# rsync -av /root/test/  /tmp/test2
sending incremental file list
created directory /tmp/test2
./
1.txt
xuexi.sorft -> xuexi.txt
xuexi.txt

sent 241 bytes  received 93 bytes  668.00 bytes/sec
total size is 31  speedup is 0.09
  • 加上L 后同步时 选项a 里面包含的小写l作用将失效
[root@xuexi-001 test]# rm -rf /tmp/test2/*
[root@xuexi-001 test]# rsync -avL /root/test/  /tmp/test2
sending incremental file list
./
1.txt
xuexi.sorft // 此时这边同步的是一个文件并非时软连接文件。
xuexi.txt

sent 267 bytes  received 76 bytes  686.00 bytes/sec
total size is 26  speedup is 0.08
[root@xuexi-001 test]# ls -l /tmp/test2/
总用量 12
-rw-r--r-- 1 root root 18 6月  18 23:19 1.txt
-rw-r--r-- 1 root root  4 6月  18 23:21 xuexi.sorft
-rw-r--r-- 1 root root  4 6月  18 23:21 xuexi.txt
  • 在/tmp/test2/目录中新增一个文件new.txt ,在同步的时候加上 --delete 删除test2中test没有的文件
[root@xuexi-001 test]# touch /tmp/test2/new.txt
[root@xuexi-001 test]# rsync -av --delete  /root/test/ /tmp/test2/
sending incremental file list
deleting new.txt
./
1.txt
xuexi.sorft -> xuexi.txt
xuexi.txt

sent 241 bytes  received 71 bytes  624.00 bytes/sec
total size is 31  speedup is 0.10
  • 在同步目录test2时,不想同步包含“.txt”的文件时可以使用 --exclude过滤指定文件
[root@xuexi-001 ~]# ls -l /root/test
总用量 8
-rw-r--r-- 1 root root 18 6月  18 23:19 1.txt
lrwxrwxrwx 1 root root  9 6月  18 23:20 xuexi.sorft -> xuexi.txt
-rw-r--r-- 1 root root  4 6月  18 23:21 xuexi.txt
[root@xuexi-001 ~]# rsync -av --exclude "*.txt" /root/test/ /tmp/test2/ 
sending incremental file list
./
xuexi.sorft -> xuexi.txt

sent 86 bytes  received 22 bytes  216.00 bytes/sec
total size is 9  speedup is 0.08
[root@xuexi-001 ~]# ls -l /tmp/test2/
总用量 0
lrwxrwxrwx 1 root root 9 6月  18 23:20 xuexi.sorft -> xuexi.txt // 因为软连接的源文件没有同步过来,所以这边显示的文件为错误的软连接。
  • -P 显示同步过程,比如速率,比-v更加详细
[root@xuexi-001 ~]# rsync -avP /root/test/ /tmp/test2/
sending incremental file list
./
1.txt
             18 100%    0.00kB/s    0:00:00 (xfr#1, to-chk=2/4)
xuexi.sorft -> xuexi.txt
xuexi.txt
              4 100%    3.91kB/s    0:00:00 (xfr#2, to-chk=0/4)

sent 241 bytes  received 60 bytes  602.00 bytes/sec
total size is 31  speedup is 0.10
  • 如果目标test2目录的文件内容发生改变,不想被源文件同步时覆盖需要加上-u选项: 加上该选项后,如果test2目录中的文件比test新,则不同步
[root@xuexi-001 ~]# vi /tmp/test2/1.txt 
111
aaa
bbb
ccc


222



333
[root@xuexi-001 ~]# cat !$
cat /tmp/test2/1.txt
111
aaa
bbb
ccc

 
222



333
[root@xuexi-001 ~]# cat /root/test/1.txt 
111

 
222



333
[root@xuexi-001 ~]# rsync -avPu /root/test/ /tmp/test2/
sending incremental file list
./

sent 130 bytes  received 19 bytes  298.00 bytes/sec
total size is 31  speedup is 0.21
[root@xuexi-001 ~]# cat /tmp/test2/1.txt 
111
aaa
bbb
ccc

 
222



333
[root@xuexi-001 ~]# cat /root/test/1.txt 
111

 
222



333

rsync 通过ssh方式同步

  • rsync -av /root/test/ 192.168.5.132:/root/test2

192.168.5.130机器

[root@xuexi-001 ~]# rsync -av /root/test/ 192.168.5.132:/root/test2/
root@192.168.5.132''s password: 
sending incremental file list
created directory /root/test2
./
1.txt
xuexi.sorft -> xuexi.txt
xuexi.txt

sent 241 bytes  received 94 bytes  95.71 bytes/sec
total size is 31  speedup is 0.09

192.168.5.132机器

[root@localhost ~]# ls 
anaconda-ks.cfg  test1  test2
[root@localhost ~]# ls -l test2
总用量 8
-rw-r--r-- 1 root root 18 6月  18 23:19 1.txt
lrwxrwxrwx 1 root root  9 6月  18 23:20 xuexi.sorft -> xuexi.txt
-rw-r--r-- 1 root root  4 6月  18 23:21 xuexi.txt
  • rsync -av -e "ssh -p 22" /root/test/ 192.168.5.132:/root/test3/······ 指定端口同步

192.168.5.130机器

[root@xuexi-001 ~]# rsync -av -e "ssh -p 22" /root/test/ 192.168.5.132:/root/test3/
root@192.168.5.132''s password: 
sending incremental file list
created directory /root/test3
./
1.txt
xuexi.sorft -> xuexi.txt
xuexi.txt

sent 241 bytes  received 94 bytes  74.44 bytes/sec
total size is 31  speedup is 0.09

192.168.5.132机器

[root@localhost ~]# ls -l test3
总用量 8
-rw-r--r-- 1 root root 18 6月  18 23:19 1.txt
lrwxrwxrwx 1 root root  9 6月  18 23:20 xuexi.sorft -> xuexi.txt
-rw-r--r-- 1 root root  4 6月  18 23:21 xuexi.txt
  • rsync 通过服务的方式同步
  • 要编辑配置文件/etc/rsyncd.conf
  • 启动服务rsync --daemon
  • 格式:rsync -av /root/test/ 192.168.5.130::module/dir/

  • rsyncd.conf样例

port=873

log file=/var/log/rsync.log

pid file=/var/run/rsyncd.pid

address=192.168.133.130

[test]

path=/root/rsync

use chroot=true

max connections=4

read only=no

list=true

uid=root

gid=root

auth users=test

secrets file=/etc/rsyncd.passwd

hosts allow=192.168.133.132


  • rsyncd.conf配置文件详解
  • port:指定在哪个端口启动rsyncd服务,默认是873端口。
  • log file:指定日志文件。
  • pid file:指定pid文件,这个文件的作用涉及服务的启动、停止等进程管理操作。
  • address:指定启动rsyncd服务的IP。假如你的机器有多个IP,就可以指定由其中一个启动rsyncd服务,如果不指定该参数,默认是在全部IP上启动。
  • []:指定模块名,里面内容自定义。
  • path:指定数据存放的路径。
  • use chroot true|false:表示在传输文件前首先chroot到path参数所指定的目录下。这样做的原因是实现额外的安全防护,但缺点是需要以roots权限,并且不能备份指向外部的符号连接所指向的目录文件。默认情况下chroot值为true,如果你的数据当中有软连接文件,阿铭建议你设置成false。

将机器B的文件同步到A机器上面(不使用密码的情况下)

A机器

1.将配置文件的样例粘贴到配置文件/etc/rsync.conf中

[root@xuexi-001 ~]# vi /etc/rsyncd.conf 

# uid = nobody
# gid = nobody
# use chroot = yes
# max connections = 4
# pid file = /var/run/rsyncd.pid
# exclude = lost+found/
# transfer logging = yes
# timeout = 900
# ignore nonreadable = yes
# dont compress   = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2

# [ftp]
#        path = /home/ftp
#        comment = ftp export area
port=873
log file=/var/log/rsync.log
pid file=/var/run/rsyncd.pid
address=192.168.5.130
[test]
path=/tmp/rsync
use chroot=true
max connections=4
read only=no
list=true
uid=root
gid=root
#auth users=test
#secrets file=/etc/rsyncd.passwd
"/etc/rsyncd.conf" 35L, 721C                                  34,1          85%

2.启动rsync 服务 3.检查rsync服务是否启动 4.检查873端口 5.创建模块test的路径目录 `````mkdir /tmp/rsync

[root@xuexi-001 ~]# rsync --daemon
[root@xuexi-001 ~]# ps aux |grep rsync
root       2074  0.0  0.0 114696   540 ?        Ss   22:21   0:00 rsync --daemon
root       2584  0.0  0.0 112676   984 pts/0    R+   23:45   0:00 grep --color=auto rsync
[root@xuexi-001 ~]# netstat -lntp 
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      919/sshd            
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1119/master         
tcp        0      0 192.168.5.130:873       0.0.0.0:*               LISTEN      2074/rsync          
tcp6       0      0 :::22                   :::*                    LISTEN      919/sshd            
tcp6       0      0 ::1:25                  :::*                    LISTEN      1119/master         
[root@xuexi-001 ~]# cat /etc/rsyncd.conf 
# /etc/rsyncd: configuration file for rsync daemon mode

# See rsyncd.conf man page for more options.

# configuration example:

# uid = nobody
# gid = nobody
# use chroot = yes
# max connections = 4
# pid file = /var/run/rsyncd.pid
# exclude = lost+found/
# transfer logging = yes
# timeout = 900
# ignore nonreadable = yes
# dont compress   = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2

# [ftp]
#        path = /home/ftp
#        comment = ftp export area
port=873
log file=/var/log/rsync.log
pid file=/var/run/rsyncd.pid
address=192.168.5.130
[test]
path=/tmp/rsync
use chroot=true
max connections=4
read only=no
list=true
uid=root
gid=root
#auth users=test
#secrets file=/etc/rsyncd.passwd
hosts allow=192.168.5.132 
[root@xuexi-001 ~]# mkdir /tmp/rsync

B机器

1.将B机器上的一个文件同步到A机器上

将B机器上的root目录下面的test3目录 同步到A机器上的/tmp/rsync目录下并改名为test110

[root@localhost ~]# rsync -avP /root/test3/ 192.168.5.130::test/test110
sending incremental file list
created directory /test110
./
1.txt
             18 100%    0.00kB/s    0:00:00 (xfr#1, to-chk=2/4)
xuexi.sorft -> xuexi.txt
xuexi.txt
              4 100%    3.91kB/s    0:00:00 (xfr#2, to-chk=0/4)

sent 242 bytes  received 91 bytes  31.71 bytes/sec
total size is 31  speedup is 0.09

2.查看A机器上的文件

[root@xuexi-001 ~]# ls /tmp/rsync/
test110

3.将A机器上的文件同步到B机器上

[root@localhost ~]# rsync -avP 192.168.5.130::test/test110  /tmp/test111
receiving incremental file list
created directory /tmp/test111
test110/
test110/1.txt
             18 100%   17.58kB/s    0:00:00 (xfr#1, to-chk=2/4)
test110/xuexi.sorft -> xuexi.txt
test110/xuexi.txt
              4 100%    3.91kB/s    0:00:00 (xfr#2, to-chk=0/4)

sent 69 bytes  received 260 bytes  31.33 bytes/sec
total size is 31  speedup is 0.09
[root@localhost ~]# ls /tmp/
test111

在同步的过程中需要将firewalld服务关闭。

systemctl stop firewalld

在同步过程中可以指定端口 使用--port 873

[root@localhost ~]# rsync -avP --port 873 192.168.5.130::test/test110  /tmp/test111

列出模块名,在服务器上的配置文件/etc/rsync.conf中将list=true 改为false 则不列出模块名

[root@localhost ~]# rsync --port=873 192.168.5.130::
test 

加入密码同步

[root@xuexi-001 ~]# vi /etc/rsyncd.conf 

# uid = nobody
# gid = nobody
# use chroot = yes
# max connections = 4
# pid file = /var/run/rsyncd.pid
# exclude = lost+found/
# transfer logging = yes
# timeout = 900
# ignore nonreadable = yes
# dont compress   = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2

# [ftp]
#        path = /home/ftp
#        comment = ftp export area
port=873
log file=/var/log/rsync.log
pid file=/var/run/rsyncd.pid
address=192.168.5.130
[test]
path=/tmp/rsync
use chroot=true
max connections=4
read only=no
list=true
uid=root
gid=root
auth users=test·····使用的用户名
secrets file=/etc/rsyncd.passwd ····密码文件名
"/etc/rsyncd.conf" 35L, 719C 
[root@xuexi-001 ~]# vi /etc/rsyncd.passwd

test:111111
[root@xuexi-001 ~]# chmod 600 /etc/rsyncd.passwd ·····需要设置文件的权限 600

B机器上测试同步效果

[root@localhost ~]# rsync -avP /root/test3/ test@192.168.5.130::test/test110 //·····这时候就需要输入用户名 test@192.168.5.130···
Password: ····输入密码
sending incremental file list
sent 124 bytes  received 12 bytes  10.07 bytes/sec
total size is 31  speedup is 0.23

在客户端B机器上定义一个密码文件 vi /etc/rsync_pass.txt

然后在同步的时候就不需要输入密码了,需要加 --password-file=/etc/rsync_pass.txt

[root@localhost ~]# vi /etc/rsync_pass.txt ······将密码文件写入 只写密码

111111
[root@localhost ~]# chmod 600 /etc/rsync_pass.txt
[root@localhost ~]# rsync -avP /root/test3/ --password-file=/etc/rsync_pass.txt test@192.168.5.130::test/test110
sending incremental file list

sent 124 bytes  received 12 bytes  12.95 bytes/sec
total size is 31  speedup is 0.23

今天关于zsync 基于HTTP的文件同步工具http同步异步的分享就到这里,希望大家有所收获,若想了解更多关于arRsync Mac文件同步工具、Fish Sync 0.6 发布,文件同步工具、FreeFileSync – 免费开源的文件同步工具、linux文件同步工具- rsync等相关知识,可以在本站进行查询。

本文标签: