Rsync not working even when the destination file exists

file-copyfile-transferlinuxrsyncsolaris

I wish to get a file /export/home/remoteuser/stopforce.sh from remotehost7 to localhost /tmp directory.

I fire the below command to establish that the file exists on the remote host:

[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

From the above we are sure that the file exist on remote although it is softlink.

I now try to get the actual file using rsync but it gives error.

[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)

The localhost is linux while the remotehost7 is solaris.

Can you please suggest why i get this error and what is the fix to the problem?

Best Answer

You are using the --copy-links option. This is documented with the text

When symlinks are encountered, the item that they point to (the referent) is copied, rather than the symlink. [...]

If your symbolic link does not point to a file that exists, then the --copy-links option would make rsync complain that it can't find the file. If --copy-links was not used, the symbolic link itself would be copied.

The fix to this problem depends on what it is you want to achieve. Either make sure that the file referenced by the symbolic link exists, or do not use the --copy-links option.

Personally, if I was using --archive I would probably be trying to make an as true copy as possible of the file hierarchy or file, in which case I would not use --copy-links (to be able to preserve symbolic links).

Related Question