Linux

即使目標文件存在,rsync 也無法正常工作

  • July 23, 2021

我希望/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。

您能否建議我為什麼會收到此錯誤以及該問題的解決方法是什麼?

您正在使用該--copy-links選項。這與文本一起記錄

當遇到符號連結時,它們指向的項目(所指對象)被複製,而不是符號連結。

$$ … $$

如果您的符號連結不指向存在的文件,則該--copy-links選項會rsync抱怨它找不到該文件。如果--copy-links使用,則將複製符號連結本身。

此問題的解決方法取決於您想要實現的目標。確保符號連結引用的文件存在,或者不使用該--copy-links選項。

就個人而言,如果我正在使用,--archive我可能會嘗試盡可能真實地複製文件層次結構或文件,在這種情況下我不會使用--copy-links(以便能夠保留符號連結)。

引用自:https://unix.stackexchange.com/questions/659614