rsync 不从远程主机复制文件

rsync 不从远程主机复制文件

我想将所有 .txt 文件从远程 test/ 目录复制到我的本地目录,但 id 不起作用

rsync --include="*.txt" --checksum --verbose --stats[电子邮件保护]:测试 。/

执行命令时的输出:

cmd=<NULL> machine=192.168.1.177 user=<NULL> path=test
cmd[0]=ssh cmd[1]=192.168.1.177 cmd[2]=rsync cmd[3]=--server cmd[4]=--sender cmd[5]=-vvvvce.LsfxC cmd[6]=. cmd[7]=test 
opening connection using: ssh 192.168.1.177 rsync --server --sender -vvvvce.LsfxC . test  (8 args)
msg checking charset: UTF-8
(Server) Protocol versions: remote=31, negotiated=31
(Client) Protocol versions: remote=31, negotiated=31
[sender] add_rule(+ *.txt)
server_sender starting pid=1458
skipping directory test
[sender] flist start=0, used=0, low=0, high=-1
send_file_list done
[sender] flist_eof=1
[sender] _exit_cleanup(code=0, file=main.c, line=818): entered
received 0 names
[Receiver] flist_eof=1
[Receiver] flist start=0, used=0, low=0, high=-1
recv_file_list done

rsync[8557] (Receiver) heap statistics:
  arena:         307200   (bytes from sbrk)
  ordblks:            1   (chunks not in use)
  smblks:             0
  hblks:              0   (chunks from mmap)
  hblkhd:             0   (bytes from mmap)
  allmem:        307200   (bytes from sbrk + mmap)
  usmblks:            0
  fsmblks:            0
  uordblks:      173968   (bytes used)
  fordblks:      133232   (bytes free)
  keepcost:      133232   (bytes in releasable chunk)

Number of files: 0
Number of created files: 0
Number of deleted files: 0
Number of regular files transferred: 0
Total file size: 0 bytes
Total transferred file size: 0 bytes
Literal data: 0 bytes
Matched data: 0 bytes
File list size: 267
Total bytes sent: 19
Total bytes received: 267

sent 19 bytes  received 267 bytes  190.67 bytes/sec
total size is 0  speedup is 0.00
client_run2 waiting on 8558
[Receiver] _exit_cleanup(code=0, file=main.c, line=1677): entered
[Receiver] _exit_cleanup(code=0, file=main.c, line=1677): about to call exit(0)

远程目录中的文件,只有一个文件包含文本

-rw-rw-r-- 1 r1ddler r1ddler 34 Jul  9 12:34 test1.txt
-rw-rw-r-- 1 r1ddler r1ddler  0 Jul  8 20:27 test10.txt
-rw-rw-r-- 1 r1ddler r1ddler  0 Jul  8 20:27 test11.txt
-rw-rw-r-- 1 r1ddler r1ddler  0 Jul  8 20:27 test12.txt
-rw-rw-r-- 1 r1ddler r1ddler  0 Jul  8 20:27 test13.txt
-rw-rw-r-- 1 r1ddler r1ddler  0 Jul  8 20:27 test2.txt
-rw-rw-r-- 1 r1ddler r1ddler  0 Jul  5 23:29 test2321.ttt
-rw-rw-r-- 1 r1ddler r1ddler  0 Jul  8 20:27 test3.txt
-rw-rw-r-- 1 r1ddler r1ddler  0 Jul  8 20:27 test4.txt
-rw-rw-r-- 1 r1ddler r1ddler  0 Jul  8 20:27 test5.txt
-rw-rw-r-- 1 r1ddler r1ddler  0 Jul  8 20:27 test6.txt
-rw-rw-r-- 1 r1ddler r1ddler  0 Jul  8 20:27 test7.txt
-rw-rw-r-- 1 r1ddler r1ddler  0 Jul  8 20:27 test8.txt
-rw-rw-r-- 1 r1ddler r1ddler  0 Jul  8 20:27 test9.txt

答案1

我使用不同的源目录名称重新创建了您的场景。此命令有效:

doug@s19:~/zzz$ rsync --checksum --verbose --stats [email protected]:zzz/*.txt ./

远程来源:

doug@s15:~/zzz$ ls -l *
-rw-r--r-- 1 doug doug 54 Jul  9 10:50 test10.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:50 test11.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:50 test12.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:50 test13.txt
-rw-r--r-- 1 doug doug  0 Jul  9 10:51 test14.txt
-rw-r--r-- 1 doug doug  0 Jul  9 10:51 test15.txt
-rw-r--r-- 1 doug doug  0 Jul  9 10:51 test16.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:49 test1.txt
-rw-r--r-- 1 doug doug  0 Jul  9 10:51 test2321.ttt
-rw-r--r-- 1 doug doug 54 Jul  9 10:49 test2.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:49 test3.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:50 test4.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:50 test5.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:50 test6.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:50 test7.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:50 test8.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:50 test9.txt

执行上述命令后的本地目标:

doug@s19:~/zzz$ ls -l
total 52
-rw-r--r-- 1 doug doug 54 Jul  9 10:54 test10.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:54 test11.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:54 test12.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:54 test13.txt
-rw-r--r-- 1 doug doug  0 Jul  9 10:54 test14.txt
-rw-r--r-- 1 doug doug  0 Jul  9 10:54 test15.txt
-rw-r--r-- 1 doug doug  0 Jul  9 10:54 test16.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:54 test1.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:54 test2.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:54 test3.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:54 test4.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:54 test5.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:54 test6.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:54 test7.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:54 test8.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:54 test9.txt

执行输出:

doug@s19:~/zzz$ rsync --checksum --verbose --stats [email protected]:zzz/*.txt ./
[email protected]'s password:
test1.txt
test10.txt
test11.txt
test12.txt
test13.txt
test14.txt
test15.txt
test16.txt
test2.txt
test3.txt
test4.txt
test5.txt
test6.txt
test7.txt
test8.txt
test9.txt

Number of files: 16 (reg: 16)
Number of created files: 16 (reg: 16)
Number of deleted files: 0
Number of regular files transferred: 16
Total file size: 702 bytes
Total transferred file size: 702 bytes
Literal data: 702 bytes
Matched data: 0 bytes
File list size: 600
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 328
Total bytes received: 1,989

sent 328 bytes  received 1,989 bytes  421.27 bytes/sec
total size is 702  speedup is 0.30

编辑:OP 想要使用--include指令,它需要--archive(或一些子集) 和--exclude。类似于:

doug@s19:~/zzz$ rsync --archive --include 'zzz' --include '*.txt' --exclude '*' --checksum --verbose --stats [email protected]:zzz ../
[email protected]'s password:
receiving incremental file list
zzz/
zzz/test1.txt
zzz/test10.txt
zzz/test11.txt
zzz/test12.txt
zzz/test13.txt
zzz/test14.txt
zzz/test15.txt
zzz/test16.txt
zzz/test2.txt
zzz/test3.txt
zzz/test4.txt
zzz/test5.txt
zzz/test6.txt
zzz/test7.txt
zzz/test8.txt
zzz/test9.txt

Number of files: 17 (reg: 16, dir: 1)
Number of created files: 16 (reg: 16)
Number of deleted files: 0
Number of regular files transferred: 16
Total file size: 702 bytes
Total transferred file size: 702 bytes
Literal data: 702 bytes
Matched data: 0 bytes
File list size: 651
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 359
Total bytes received: 2,048

sent 359 bytes  received 2,048 bytes  534.89 bytes/sec
total size is 702  speedup is 0.29
doug@s19:~/zzz$ ls -l
total 52
-rw-r--r-- 1 doug doug 54 Jul  9 10:50 test10.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:50 test11.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:50 test12.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:50 test13.txt
-rw-r--r-- 1 doug doug  0 Jul  9 10:51 test14.txt
-rw-r--r-- 1 doug doug  0 Jul  9 10:51 test15.txt
-rw-r--r-- 1 doug doug  0 Jul  9 10:51 test16.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:49 test1.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:49 test2.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:49 test3.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:50 test4.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:50 test5.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:50 test6.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:50 test7.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:50 test8.txt
-rw-r--r-- 1 doug doug 54 Jul  9 10:50 test9.txt
doug@s19:~/zzz$

相关内容