我希望/export/home/remoteuser/stopforce.sh
从remotehost7 获取一个文件到localhost/tmp
目录。
我触发以下命令来确定该文件存在于远程主机上:
[localuser@localhost ~]$ ssh remoteuser@remotehost7 ' ls -ltr /export/home/remoteuser/stopforce.sh'
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 *** #
##################################################################
lrwxrwxrwx 1 remoteuser oinstall 65 Aug 30 2015 /export/home/remoteuser/stopforce.sh -> /u/marsh/external_products/apache-james-3.0/bin/stopforce.sh
从上面我们可以确定该文件存在于远程,尽管它是软链接。
我现在尝试获取实际的文件,rsync
但它给出了错误。
[localuser@localhost ~]$ /bin/rsync --delay-updates -F --compress --copy-links --archive remoteuser@remotehost7:/export/home/remoteuser/stopforce.sh /tmp/
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 *** #
##################################################################
rsync: [sender] link_stat "/export/home/remoteuser/stopforce.sh" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1651) [Receiver=3.1.2]
rsync: [Receiver] write error: Broken pipe (32)
localhost 是linux,而remotehost7 是solaris。
您能否建议我为什么会收到此错误以及解决该问题的方法是什么?
答案1
您正在使用该--copy-links
选项。这是用文本记录的
当遇到符号链接时,将复制它们指向的项目(引用对象),而不是符号链接。 [...]
如果您的符号链接未指向存在的文件,则该--copy-links
选项会rsync
抱怨找不到该文件。如果--copy-links
是不是使用时,符号链接本身将被复制。
此问题的解决方法取决于您想要实现的目标。确保符号链接引用的文件存在,或者不使用该--copy-links
选项。
就我个人而言,如果我正在使用,--archive
我可能会尝试尽可能真实地复制文件层次结构或文件,在这种情况下我不会使用--copy-links
(为了能够保留符号链接)。