I have a directory that contains symbolic links to other directories located on different media on my system:


But the symbolic links show up as:


How can I perform an rsync that follows the symbolic links?


rsync -XXX /files/ user@server:/files/

3 Answers 3


The -L flag to rsync will sync the contents of files or directories linked to, rather than the symbolic link.

  • 1
    When I do this, all the receiver symbolic links get deleted and my sender starts re-sending the files.
    – ensnare
    Mar 10, 2011 at 16:40
  • 5
    Hi -- these are directories. I got this to work with the -K flag.
    – ensnare
    Mar 10, 2011 at 21:20
  • 6
    I'm sure SO is making me more stupid..
    – John Hunt
    Nov 7, 2014 at 11:53
  • 10
    To clarify, -LK if you want to follow both symlinked files and directories
    – Mahn
    Jul 14, 2016 at 21:14
  • 3
    Always be careful when following such suggestions. Test, test, and test before your carry out product run! -L itself will remove all symlinks on your receiver side!
    – HongboZhu
    Jul 5, 2019 at 10:16

You need both -L and -K if you have symlinks on both sides, e.g. you already had your 1st rsync done and want to update the backup using rsync.

    -L, --copy-links            transform symlink into referent file/dir
    -K, --keep-dirlinks         treat symlinked dir on receiver as dir

In such cases, if you use only -L, the symlinks on the receiver side will be wiped out and new real dir will be made.

  • 1
    This should have been the selected answer.
    – ychaouche
    Nov 16, 2020 at 9:45

Just ran into this problem. And if you want rsync to treat symlinked directories as directories, you want the K option

rsync -K /files/ user@server:/files/

  • You might also want to add the --copy-unsafe-links option Aug 2, 2016 at 16:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .