[Bug 2395] New: problems copying from a dir that includes a symlink in the path

samba-bugs at samba.org samba-bugs at samba.org
Sun Feb 27 22:25:10 GMT 2005


           Summary: problems copying from a dir that includes a symlink in
                    the path
           Product: rsync
           Version: 2.6.4
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P3
         Component: core
        AssignedTo: wayned at samba.org
        ReportedBy: Dave at Yost.com
         QAContact: rsync-qa at samba.org
                CC: Dave at Yost.com

I've put together a nightly backup script using rsync, which you can have if you
want.  It basically rsyncs a dir to a dir on the remote machine, where the
remote dir's name is an ISO 8601 timestamp.

Today I tried to enhance this system to get a file from the repository, and
since I use symlinks in the pathnames in the repository, I hit what I consider
to be bugs in rsync.  The attached script demonstrates what I mean.

Basically, if you try to
  rsync a/b .
were a is a symlink, it doesn't work as expected given various combinations of
-R, -l, and -L options.


# rsync problems with copying from a dir that includes a symlink in the path
# 2005-02-27 Dave at Yost.com

setupSource() {
	rm -rf source/dir source/symlink
	mkdir -p source/dir
	ln -s dir source/s
	ln -s referent source/dir/s
	echo nothing > source/dir/file

setupCorrectOutput() {
	rm -rf correct-output
	mkdir  correct-output
	cd     correct-output
	for x in ${opts[@]}
		mkdir dest${x}
		case $x in
		*R*) mkdir -p dest${x}/s
		     case $x in
		     *L*) cp -p ../source/dir/file dest${x}/s/file
		          cp -p ../source/dir/file dest${x}/s/symlink
		     *l*) cp -p ../source/dir/file dest${x}/s/file
		          ln -s referent           dest${x}/s/symlink
		     *)   cp -p ../source/dir/file dest${x}/s/file
		*)   case $x in
		     *L*) cp -p ../source/dir/file dest${x}/file
		          cp -p ../source/dir/file dest${x}/symlink
		     *l*)  cp -p ../source/dir/file dest${x}/file
		          ln -s referent           dest${x}/symlink
		     *)   cp -p ../source/dir/file dest${x}/file
	cd ..

test() {
	rm -rf   $dest
	mkdir -p $dest
	cd source
	echo '###' rsync $opts s/$file ../$dest
	           rsync $opts s/$file ../$dest
	cd ..
	ls -ld $(find $dest) \
	| sed 's,...........................................,  ,'

	-rLL  # hack for for case-insensitive file systems

testGroup() {
	for x in ${opts[@]}
		test $x $1

rm -rf output
mkdir  output

testGroup file
testGroup symlink

dodiff() {
	find correct-output -type $1 | sed 's,correct-output/,,' | sed "s,$, $1," >> $c
	find output         -type $1 | sed 's,output/,,'         | sed "s,$, $1," >> $a

dodiff f
dodiff l

sort $c > $c-sorted
sort $a > $a-sorted

echo '###' This diff should produce only lines starting with '='
echo '###' diff $1 correct vs actual
/usr/bin/diff       --old-line-format='< %l
'             --unchanged-line-format='= %l
'                   --new-line-format='> %l
'             $c-sorted $a-sorted

Configure bugmail: https://bugzilla.samba.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.

More information about the rsync mailing list