美文网首页Linux
4-10.6 Linux 中的文件同步传输 --- rsync

4-10.6 Linux 中的文件同步传输 --- rsync

作者: 捌千里路雲和月 | 来源:发表于2021-08-11 01:02 被阅读0次
  • -v:显示传输过程中的详细信息,-v 可以用通过增加 v参数的数量来显示更多详尽的信息。最全面,最详尽的传输信息是 5个v(-vvvvv)。
  • 4-10.6 内容:
    通过 rsync -a -v 把文件传输到目标目录。标识 -v 不同数量所增加了哪些信息内容。
  • 操作步骤:
    1、新建一个 backups_v 目录用作 -v 参数测试的目标目录。
[root@localhost test]# mkdir backups_v
[root@localhost test]# tree
.
├── backups_v
└── SRC
    ├── demo1.txt
    ├── demo2.txt
    └── demo3.txt

2 directories, 3 files
[root@localhost test]# 

2、为了清晰一点,先删除 SRC 目录下的文件,重新创建 1 个文件。

[root@localhost test]# 
[root@localhost test]# ll SRC/
total 8
-rw-rw-rw-. 1 root root  6 Aug  8 22:41 demo1.txt
-rw-rw-rw-. 1 root root 10 Aug  8 22:47 demo2.txt
-rw-rw-rw-. 1 root root  0 Jul 22 22:44 demo3.txt
[root@localhost test]# 
[root@localhost test]# rm -rf SRC/*    ## 删除 SRC目录下的所有文件
[root@localhost test]# 
[root@localhost test]# ll SRC/
total 0
[root@localhost test]# touch SRC/demo1.txt    ## SRC目录下只创建一个 demo1.txt
[root@localhost test]# 
[root@localhost test]# ll SRC/
total 0
-rw-r--r--. 1 root root 0 Aug 10 22:13 demo1.txt
[root@localhost test]# 

3、用 rsync -a SRC/demo1.txt 到 backups_v 目录。

## 没有 -v 的加持,传输数据时不会显示信息。
[root@localhost test]# rsync -a SRC/demo1.txt backups_v/
[root@localhost test]# 
[root@localhost test]# tree
.
├── backups_v
│   └── demo1.txt
└── SRC
    └── demo1.txt

2 directories, 2 files
[root@localhost test]# 

4、用 rsync -a -v SRC/demo1.txt 到 backups_v 目录,并改名为demo2.txt。

[root@localhost test]# rsync -a -v SRC/demo1.txt backups_v/demo2.txt
## {... 花括号内是 -v 所显示的传输信息
sending incremental file list    
demo1.txt

sent 91 bytes  received 35 bytes  252.00 bytes/sec
total size is 0  speedup is 0.00
 ##...}   
[root@localhost test]# 
[root@localhost test]# tree
.
├── backups_v
│   ├── demo1.txt
│   └── demo2.txt    ## 生成 demo2.txt
└── SRC
    └── demo1.txt

2 directories, 3 files
[root@localhost test]# 

5、用 rsync -a -vv SRC/demo1.txt 到 backups_v 目录,并改名为demo3.txt。

[root@localhost test]# 
[root@localhost test]# rsync -a -vv SRC/demo1.txt backups_v/demo3.txt
sending incremental file list

##{...花括号内是比 -v 多出的内容
delta-transmission disabled for local transfer or --whole-file
##...}

demo3.txt is uptodate

##{...花括号内是比 -v 多出的内容
total: matches=0  hash_hits=0  false_alarms=0 data=0
##...}

sent 91 bytes  received 102 bytes  386.00 bytes/sec
total size is 0  speedup is 0.00
[root@localhost test]# 
[root@localhost test]# tree
.
├── backups_v
│   ├── demo1.txt
│   ├── demo2.txt
│   └── demo3.txt    ## 生成 demo3.txt
└── SRC
    └── demo1.txt

2 directories, 4 files
[root@localhost test]# 

6、用 rsync -a -vvv SRC/demo1.txt 到 backups_v 目录,并改名为demo4.txt。

[root@localhost test]# 
[root@localhost test]# rsync -a -vvv SRC/demo1.txt backups_v/demo4.txt
sending incremental file list

## {... 花括号内是比 -vv 多出的内容
[sender] make_file(demo1.txt,*,0)
send_file_list done
send_files starting
server_recv(2) starting pid=1665
recv_file_name(demo1.txt)
received 1 names
recv_file_list done
get_local_name count=1 backups_v/demo4.txt
generator starting pid=1665
##...}

delta-transmission disabled for local transfer or --whole-file

## {... 花括号内是比 -vv 多出的内容
recv_generator(demo4.txt,1)
send_files(1, SRC/demo1.txt)
send_files mapped SRC/demo1.txt of size 0
calling match_sums SRC/demo1.txt
##...}

demo1.txt

## {... 花括号内是比 -vv 多出的内容
sending file_sum
false_alarms=0 hash_hits=0 matches=0
sender finished SRC/demo1.txt
generate_files phase=1
recv_files(1) starting
recv_files(demo4.txt)
got file_sum
set modtime of .demo4.txt.bG1QTi to (1628604804) Tue Aug 10 22:13:24 2021
renaming .demo4.txt.bG1QTi to demo4.txt
send_files phase=1
recv_files phase=1
generate_files phase=2
send_files phase=2
send files finished
##...}

total: matches=0  hash_hits=0  false_alarms=0 data=0

## {... 花括号内是比 -vv 多出的内容
recv_files phase=2
recv_files finished
generate_files phase=3
generate_files finished
##...}
sent 91 bytes  received 594 bytes  1,370.00 bytes/sec
total size is 0  speedup is 0.00

## {... 花括号内是比 -vv 多出的内容
[sender] _exit_cleanup(code=0, file=main.c, line=1179): about to call exit(0)
##...}

[root@localhost test]# 
[root@localhost test]# tree
.
├── backups_v
│   ├── demo1.txt
│   ├── demo2.txt
│   ├── demo3.txt
│   └── demo4.txt     ## 生成 demo4.txt
└── SRC
    └── demo1.txt

2 directories, 5 files
[root@localhost test]# 

7、用 rsync -a -vvvv SRC/demo1.txt 到 backups_v 目录,并改名为demo5.txt。

[root@localhost test]# rsync -a -vvvv SRC/demo1.txt backups_v/demo5.txt

## {... 花括号内是比 -vvv 多出的内容
cmd=<NULL> machine=<NULL> user=<NULL> path=backups_v/demo5.txt
cmd[0]=. cmd[1]=backups_v/demo5.txt 
msg checking charset: UTF-8
(Server) Protocol versions: remote=31, negotiated=31
(Client) Protocol versions: remote=31, negotiated=31
##...} 

sending incremental file list
[sender] make_file(demo1.txt,*,0)

## {... 花括号内是比 -vvv 多出的内容
[sender] flist start=1, used=1, low=0, high=0
[sender] i=1 SRC demo1.txt mode=0100644 len=0 uid=0 gid=0 flags=1005
##...} 

send_file_list done

## {... 花括号内是比 -vvv 多出的内容
[sender] flist_eof=1
file list sent
##...} 

send_files starting
server_recv(2) starting pid=1669

## {... 花括号内是比 -vvv 多出的内容
uid 0() maps to 0
gid 0() maps to 0
##...} 

recv_file_name(demo1.txt)
received 1 names

## {... 花括号内是比 -vvv 多出的内容
[Receiver] flist start=1, used=1, low=0, high=0
[Receiver] i=1 1 demo1.txt mode=0100644 len=0 uid=0 gid=0 flags=1000
##...} 

recv_file_list done

## {... 花括号内是比 -vvv 多出的内容
[Receiver] flist_eof=1
##...} 

get_local_name count=1 backups_v/demo5.txt
generator starting pid=1669
delta-transmission disabled for local transfer or --whole-file
recv_generator(demo5.txt,1)
send_files(1, SRC/demo1.txt)

## {... 花括号内是比 -vvv 多出的内容
count=0 n=0 rem=0
##...} 

send_files mapped SRC/demo1.txt of size 0
calling match_sums SRC/demo1.txt
demo1.txt
sending file_sum
false_alarms=0 hash_hits=0 matches=0
sender finished SRC/demo1.txt
generate_files phase=1
recv_files(1) starting
recv_files(demo5.txt)
got file_sum
set modtime of .demo5.txt.vyCUfy to (1628604804) Tue Aug 10 22:13:24 2021
renaming .demo5.txt.vyCUfy to demo5.txt
send_files phase=1
recv_files phase=1
generate_files phase=2
send_files phase=2
send files finished
total: matches=0  hash_hits=0  false_alarms=0 data=0
recv_files phase=2
recv_files finished
generate_files phase=3
generate_files finished

## {... 花括号内是比 -vvv 多出的内容
client_run waiting on 1669
##...} 

sent 91 bytes  received 790 bytes  1,762.00 bytes/sec
total size is 0  speedup is 0.00

## {... 花括号内是比 -vvv 多出的内容
[sender] _exit_cleanup(code=0, file=main.c, line=1179): entered
##...} 

[sender] _exit_cleanup(code=0, file=main.c, line=1179): about to call exit(0)
[root@localhost test]# 
[root@localhost test]# tree
.
├── backups_v
│   ├── demo1.txt
│   ├── demo2.txt
│   ├── demo3.txt
│   ├── demo4.txt
│   └── demo5.txt    ## 生成 demo5.txt
└── SRC
    └── demo1.txt

2 directories, 6 files
[root@localhost test]# 

8、用 rsync -a -vvvvv SRC/demo1.txt 到 backups_v 目录,并改名为demo6.txt。

[root@localhost test]# rsync -a -vvvvv SRC/demo1.txt backups_v/demo6.txt

## {... 花括号内是比 -vvvv 多出的内容
FILE_STRUCT_LEN=24, EXTRA_LEN=4
##...} 

cmd=<NULL> machine=<NULL> user=<NULL> path=backups_v/demo6.txt
cmd[0]=. cmd[1]=backups_v/demo6.txt 
msg checking charset: UTF-8
(Server) Protocol versions: remote=31, negotiated=31
(Client) Protocol versions: remote=31, negotiated=31
sending incremental file list
[sender] change_dir(/root/test/SRC)
[sender] make_file(demo1.txt,*,0)
[sender] flist start=1, used=1, low=0, high=0
[sender] i=1 SRC demo1.txt mode=0100644 len=0 uid=0 gid=0 flags=1005
send_file_list done
[sender] flist_eof=1
file list sent
send_files starting
server_recv(2) starting pid=1690
uid 0() maps to 0
gid 0() maps to 0
recv_file_name(demo1.txt)
received 1 names
[Receiver] flist start=1, used=1, low=0, high=0
[Receiver] i=1 1 demo1.txt mode=0100644 len=0 uid=0 gid=0 flags=1000
recv_file_list done
[Receiver] flist_eof=1
get_local_name count=1 backups_v/demo6.txt

## {... 花括号内是比 -vvvv 多出的内容
[Receiver] change_dir(/root/test/backups_v)
##...} 

generator starting pid=1690
delta-transmission disabled for local transfer or --whole-file
recv_generator(demo6.txt,1)
send_files(1, SRC/demo1.txt)
count=0 n=0 rem=0
send_files mapped SRC/demo1.txt of size 0
calling match_sums SRC/demo1.txt
demo1.txt
sending file_sum
false_alarms=0 hash_hits=0 matches=0
sender finished SRC/demo1.txt
generate_files phase=1
recv_files(1) starting
recv_files(demo6.txt)
got file_sum
set modtime of .demo6.txt.Fd0KT4 to (1628604804) Tue Aug 10 22:13:24 2021
renaming .demo6.txt.Fd0KT4 to demo6.txt
send_files phase=1
recv_files phase=1
generate_files phase=2
send_files phase=2
send files finished
total: matches=0  hash_hits=0  false_alarms=0 data=0
recv_files phase=2
recv_files finished
generate_files phase=3
generate_files finished
client_run waiting on 1690

sent 91 bytes  received 838 bytes  1,858.00 bytes/sec
total size is 0  speedup is 0.00
[sender] _exit_cleanup(code=0, file=main.c, line=1179): entered
[sender] _exit_cleanup(code=0, file=main.c, line=1179): about to call exit(0)
[root@localhost test]# 
[root@localhost test]# tree
.
├── backups_v
│   ├── demo1.txt
│   ├── demo2.txt
│   ├── demo3.txt
│   ├── demo4.txt
│   ├── demo5.txt
│   └── demo6.txt  ## 生成 demo6.txt
└── SRC
    └── demo1.txt

2 directories, 7 files
[root@localhost test]# 

9、检查源文件属性和目标目录文件属性(属性一致)。

[root@localhost test]# ll SRC/
total 0
-rw-r--r--. 1 root root 0 Aug 10 22:13 demo1.txt
[root@localhost test]# 
[root@localhost test]# ll backups_v/
total 0
-rw-r--r--. 1 root root 0 Aug 10 22:13 demo1.txt
-rw-r--r--. 1 root root 0 Aug 10 22:13 demo2.txt
-rw-r--r--. 1 root root 0 Aug 10 22:13 demo3.txt
-rw-r--r--. 1 root root 0 Aug 10 22:13 demo4.txt
-rw-r--r--. 1 root root 0 Aug 10 22:13 demo5.txt
-rw-r--r--. 1 root root 0 Aug 10 22:13 demo6.txt
  • 上述的测试,-v 可以显示文件传输过程中的信息。基本信息 -v,随着 v 数量增加会逐步列出更为详细的信息。最详尽的传输信息是 -vvvvv。

相关文章

网友评论

    本文标题:4-10.6 Linux 中的文件同步传输 --- rsync

    本文链接:https://www.haomeiwen.com/subject/tzbtbltx.html