我的问题只是我试图解决的一个更大问题的一小部分。
该问题始于rsync
非常复杂且由 ansible 构建且不起作用的命令......此处报告:
我希望从一个简单的 rsync 命令开始,将文件夹从远程主机复制到本地。
它复制的是远程是一个文件,但如果远程是一个目录则失败。
$ /bin/rsync --version
rsync version 3.1.2 protocol version 31
Copyright (C) 1996-2015 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
append, ACLs, xattrs, iconv, symtimes, prealloc
rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. See the GNU
General Public Licence for details.
[mylocaluser@mylocalhost myremotehost]$ uname -a
Linux mylocalhost 3.10.0-1160.76.1.el7.x86_64 #1 SMP Tue Jul 26 14:15:37 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Rsync 为文件工作:
$ /bin/rsync -v myremoteuser@myremotehost:/tmp/Deployments/pay.war /web/playbooks/automation/getfiles/tmpfiles/4/E5EA787E/myremotehost/
This system is for the use by authorized users only. All data contained
on all systems is owned by the company and may be monitored, intercepted,
recorded, read, copied, or captured in any manner and disclosed in any
manner, by authorized company personnel. Users (authorized or unauthorized)
have no explicit or implicit expectation of privacy. Unauthorized or improper
use of this system may result in administrative, disciplinary action, civil
and criminal penalties. Use of this system by any user, authorized or
unauthorized, constitutes express consent to this monitoring, interception,
recording, reading, copying, or capturing and disclosure.
IF YOU DO NOT CONSENT, LOG OFF NOW.
##################################################################
# *** This Server is using Centrify *** #
# *** Remember to use your Active Directory account *** #
# *** password when logging in *** #
##################################################################
pay.war
sent 43 bytes received 83 bytes 252.00 bytes/sec
total size is 0 speedup is 0.00
但是,当我提供目录而不是文件时,它不起作用。
$ /bin/rsync -v myremoteuser@myremotehost:/tmp/Deployments/ /web/playbooks/automation/getfiles/tmpfiles/4/E5EA787E/myremotehost/
This system is for the use by authorized users only. All data contained
on all systems is owned by the company and may be monitored, intercepted,
recorded, read, copied, or captured in any manner and disclosed in any
manner, by authorized company personnel. Users (authorized or unauthorized)
have no explicit or implicit expectation of privacy. Unauthorized or improper
use of this system may result in administrative, disciplinary action, civil
and criminal penalties. Use of this system by any user, authorized or
unauthorized, constitutes express consent to this monitoring, interception,
recording, reading, copying, or capturing and disclosure.
IF YOU DO NOT CONSENT, LOG OFF NOW.
##################################################################
# *** This Server is using Centrify *** #
# *** Remember to use your Active Directory account *** #
# *** password when logging in *** #
##################################################################
skipping directory .
sent 8 bytes received 30 bytes 25.33 bytes/sec
total size is 0 speedup is 0.00
请建议。
根据
rsync --help
:因此,当您要复制目录时,您必须添加
-r
or--recursive
选项rysnc:
使用
rsync -a
代替普通的rsync
.如果没有
-a
(--archive
) 标志,您既不会递归复制,也不会获得文件元数据。至少,需要使用 ( ) 复制的文件修改时间 ( )mtime
才能-t
有选择地跳过它认为已复制的文件。如果确定文件的大小和最后修改时间在源和目标上相同,则它更愿意避免执行校验和,但显然如果没有将文件修改时间复制到目标,这些将不匹配并且无法优化其传输算法。--times
rsync
rsync
rsync