When I try to rsync directory1 to directory2 that have symbolic files that point to the same files in directory1, rsync replace all the symbolic files with real files.
I tried to add -L but it didn't help, -K is for symbolic directories. Is there a flag to keep the symbolic files in the target?
command:
mkdir dir1
cd dir1
echo "TEST" > file1
cd ..
cp -as /HOME/dir1 dir2
now dir2 have a symbolic file that point to the file in dir1.
When I try to run:
rsync -nKLri dir1/ dir2/
I get:
>f+++++++++ file1
--ignore-existing? – Kusalananda Aug 03 '22 at 12:14rsynccould achieve what they seem to want – Chris Davies Aug 03 '22 at 12:33--ignore-existingoption does exactly what it describes: it completely ignores any existing file in the destination directory tree – Chris Davies Aug 03 '22 at 12:34--ignore-existingdoesn't help – Jeries Aug 03 '22 at 13:04rsync's archive option-a'everything' is copied as is, including symlinks, but excluding hardlinks. When you add-Hthat isrsync -Hayou also copy hardlinks as hardlinks, give them the same inode (if the file system supports it). Searching for hardlinks costs time and effort, so it is not default. Instead of-ayou can also use the-lto copy symlinks as symlinks. Notice that symlinks via-lmight not work in the backup environment, however, after restore to the original location they will work. So, is it a backup or do you want the symlinks to work in the target? – sudodus Aug 03 '22 at 16:43dir2and I want to usersyncto copy only changed files fromdir1todir2,dir1have only regular files (there is no symbolic files) – Jeries Aug 04 '22 at 13:16dir1with the same name as the symbolic links indir2? In that case, what do you want to happen? Do you want the symbolic links to survive? Or do you want the regular files fromdir1to replace them? Is this some kind of backup (one way) or synchronizing (both ways so that the newest files should survive)? – sudodus Aug 04 '22 at 15:40dir1with the same name asdir2, if the file is modified then it have to replace the file indir2– Jeries Aug 04 '22 at 16:53dir2is a symlink and the file indir1is a regular file they are different. Always. It makes things very complicated, if you want to compare with what the symlink is pointing to. So I would recommend that you let symlinks indir2to be replaced. If you don't want that, please explain why. Otherwise it is difficult to help. – sudodus Aug 05 '22 at 07:05