Rsync error: symlink has no referent

backupchrootcygwin;rsnapshotrsync

I am trying to configure rsnapshot (which uses rsync) to backup a Windows server but I am having trouble with rsync being unable to follow a symlink on the server to be backed up.

Setup:

  • Windows Server 2008 R2 with Cygwin installed which holds files to be backed up
  • ArchLinux server on the same network which should backup files from the Windows server
  • The Windows server has sshd installed and functioning
  • The Windows server does not have a running rsync daemon (As far as I can tell), but I can use rsync over ssh to connect to the Windows server from the Linux sever and copy files.
  • Because an application keeps some of the files to be backed up constantly open, the Windows server is configured to create Volume Shadow Copies of the drive that contains the data to be backed up
  • I use the following script to create a link to the latest shadow copy volume so that it can be accessed by rsync:

    #!/bin/sh
    # Mount the latest shadow copy for the specified volume
    
    VOLUME="D:"
    LINK_NAME="E:\\latest-data-shadow-copy"
    
    
    SHADOW_VOLUME=`vssadmin list shadows /for=$VOLUME | grep "Shadow Copy Volume:" | tail -1 | tr -s ' ' | cut -d ' ' -f5`
    SHADOW_VOLUME+="\\"
    
    rm $LINK_NAME
    cmd.exe /c mklink /d "$LINK_NAME" "$SHADOW_VOLUME"
    

The Problem

When I try to run rsnapshot to backup the data on the symlinked shadow copy volume, it returns the following error:

    symlink has no referent: "/cygdrive/e/latest-data-shadow-copy"

This is the rsync command that rsnapshot calls:

    /usr/bin/rsync -a --delete --numeric-ids --relative --delete-excluded --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r --rsh=/usr/bin/ssh 'user@windowsip:/cygdrive/e/latest-data-shadow-copy/data-folder/' /media/backup-drive-1/.sync/

However if I try to use scp to copy files from the symlinked shadow copy volume it works fine:

    scp user@windowsip:/cygdrive/e/latest-data-shadow-copy/data-folder/test-file.txt test-file.txt

As far as I can figure out, this seems to suggest that the cause of the rsync error is that it is being run in chroot on the Windows server preventing it from accessing the symlinked shadow copy volume.

I tried creating a /etc/rsync.conf and adding the following:

    use chroot = no

but it has no effect on the error. I assume this is because this is a config file for the rsync daemon which I am not running.

Questions

  • What is preventing rsync from accessing the symlinked shadow copy while scp can access the files without issue?
  • If the issue is the use chroot rsync setting, how do I change it if I am not running an rsync daemon?

Thank you for your responses in advance!

Best Answer

I had similar problem with symlink has no referent:

The root cause was: the link was pointing to non-existent place. Just someone in organisation changed file system structure after links were created and not updated the links.

Solution was one of following:

  1. Fix the links pointing into existing location.
  2. Remove links as not necessary (is no one but rsync use them).
  3. Exclude attempt of rsync to access your link with option --exclude '/cygdrive/e/latest-data-shadow-copy'. This is asked "prevention" method, however, maybe not the best one, so last option proposed.
Related Question