rsync handling of symlinks
Frank Mills via rsync <[email protected]> Sun, 31 May 2026 02:59:44 +0000
| Newsgroups | gmane.network.rsync.general |
|---|---|
| Message-ID | <PH0PR17MB5741761BF52E98F342D4744EAF142@PH0PR17MB5741.namprd17.prod.outlook.com> |
--===============8630795780543347592==
Content-Language: en-US
Content-Type: multipart/alternative;
boundary="_000_PH0PR17MB5741761BF52E98F342D4744EAF142PH0PR17MB5741namp_"
--_000_PH0PR17MB5741761BF52E98F342D4744EAF142PH0PR17MB5741namp_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I haven't found any postings on this in an internet search and the empirica=
l behavior doesn't seem to match what's described in the man page. The syst=
em is running rsync version 3.1.3 protocol version 31.
I created a test directory and tried several rsync parameters (such as -a).=
After working through the error messages that were generated, the followin=
g did not generate errors.
rsync -rLkHtUuv --log-file=3Dabc_test.txt ~/a/b/ c >& abc_err.txt
Within the source directory is a symlink that points to another file within=
the same directory.
~/a/b/test_link -> ~/a/b/linked_file
The above rsync options correctly change the symlink to a file whose conten=
t is the same as the target file. So, these rsync options are operating as =
expected.
Where I get behavior that doesn't seem to match documentation is when I try=
to keep symlinks as symlinks.
rsync -rltUv --log-file=3Dabc_test.txt ~/a/b/ c >& abc_err.txt
In the copied directory, the symlink that was in the original directory has=
been omitted and the symlink has not been replaced by the target file. I g=
et similar behavior with rsync -a.
Since the target and symlink are in the same directory, my understanding fr=
om the man page is that rsync should copy the symlink as a symlink. Any sug=
gestions for how to preserve symlinks that are within the directory structu=
re being copied? Thanks.
--_000_PH0PR17MB5741761BF52E98F342D4744EAF142PH0PR17MB5741namp_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
<style type=3D"text/css" style=3D"display:none;"> P {margin-top:0;margin-bo=
ttom:0;} </style>
</head>
<body dir=3D"ltr">
<div class=3D"elementToProof" style=3D"line-height: normal; margin: 0px; fo=
nt-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helveti=
ca, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I haven't found any postings on this in an internet search and the empirica=
l behavior doesn't seem to match what's described in the man page. The syst=
em is running rsync version 3.1.3 protocol version 31. </div>
<div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo=
nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; c=
olor: rgb(0, 0, 0);">
<br>
</div>
<p class=3D"elementToProof" style=3D"margin: 0px;"><span style=3D"font-fami=
ly: Aptos, sans-serif; font-size: 12pt; color: black;">I created a test dir=
ectory and tried several rsync parameters (such as -a). After working throu=
gh the error messages that were generated,
the following did not generate errors. </span></p>
<p class=3D"elementToProof" style=3D"margin: 0px;"><span style=3D"font-fami=
ly: Aptos, sans-serif; font-size: 12pt; color: black;">rsync -rLkHtUuv --lo=
g-file=3Dabc_test.txt ~/a/b/ c >& abc_err.txt</span></p>
<p class=3D"elementToProof" style=3D"margin: 0px;"><span style=3D"font-fami=
ly: Aptos, sans-serif; font-size: 12pt; color: black;"> </span></p>
<p class=3D"elementToProof" style=3D"margin: 0px;"><span style=3D"font-fami=
ly: Aptos, sans-serif; font-size: 12pt; color: black;">Within the source di=
rectory is a symlink that points to another file within the same directory.=
</span></p>
<p class=3D"elementToProof" style=3D"margin: 0px;"><span style=3D"font-fami=
ly: Aptos, sans-serif; font-size: 12pt; color: black;">~/a/b/test_link ->=
; ~/a/b/linked_file</span></p>
<p class=3D"elementToProof" style=3D"margin: 0px;"><span style=3D"font-fami=
ly: Aptos, sans-serif; font-size: 12pt; color: black;"> </span></p>
<p class=3D"elementToProof" style=3D"margin: 0px;"><span style=3D"font-fami=
ly: Aptos, sans-serif; font-size: 12pt; color: black;">The above rsync opti=
ons correctly change the symlink to a file whose content is the same as the=
target file. So, these rsync options
are operating as expected. </span></p>
<p class=3D"elementToProof" style=3D"margin: 0px;"><span style=3D"font-fami=
ly: Aptos, sans-serif; font-size: 12pt; color: black;"> </span></p>
<p class=3D"elementToProof" style=3D"margin: 0px;"><span style=3D"font-fami=
ly: Aptos, sans-serif; font-size: 12pt; color: black;">Where I get behavior=
that doesn't seem to match documentation is when I try to keep symlinks as=
symlinks. </span></p>
<p class=3D"elementToProof" style=3D"margin: 0px;"><span style=3D"font-fami=
ly: Aptos, sans-serif; font-size: 12pt; color: black;">rsync -rltUv --log-f=
ile=3Dabc_test.txt ~/a/b/ c >& abc_err.txt</span></p>
<p class=3D"elementToProof" style=3D"margin: 0px;"><span style=3D"font-fami=
ly: Aptos, sans-serif; font-size: 12pt; color: black;"> </span></p>
<p class=3D"elementToProof" style=3D"margin: 0px;"><span style=3D"font-fami=
ly: Aptos, sans-serif; font-size: 12pt; color: black;">In the copied direct=
ory, the symlink that was in the original directory has been omitted and th=
e symlink has not been replaced by the
target file. I get similar behavior with rsync -a. </span></p>
<p class=3D"elementToProof" style=3D"margin: 0px;"><span style=3D"font-fami=
ly: Aptos, sans-serif; font-size: 12pt; color: black;"> </span></p>
<p class=3D"elementToProof" style=3D"margin: 0px;"><span style=3D"font-fami=
ly: Aptos, sans-serif; font-size: 12pt; color: black;">Since the target and=
symlink are in the same directory, my understanding from the man page is t=
hat rsync should copy the symlink as a
symlink. Any suggestions for how to preserve symlinks that are within the =
directory structure being copied? Thanks. </span></p>
<div class=3D"elementToProof" style=3D"margin-right: 0px; margin-left: 0px;=
font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helv=
etica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
</body>
</html>
--_000_PH0PR17MB5741761BF52E98F342D4744EAF142PH0PR17MB5741namp_--
--===============8630795780543347592==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
--
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html
--===============8630795780543347592==--