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:14rsync
could achieve what they seem to want – Chris Davies Aug 03 '22 at 12:33--ignore-existing
option 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-existing
doesn'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-H
that isrsync -Ha
you 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-a
you can also use the-l
to copy symlinks as symlinks. Notice that symlinks via-l
might 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:43dir2
and I want to usersync
to copy only changed files fromdir1
todir2
,dir1
have only regular files (there is no symbolic files) – Jeries Aug 04 '22 at 13:16dir1
with 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 fromdir1
to 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:40dir1
with the same name asdir2
, if the file is modified then it have to replace the file indir2
– Jeries Aug 04 '22 at 16:53dir2
is a symlink and the file indir1
is 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 indir2
to be replaced. If you don't want that, please explain why. Otherwise it is difficult to help. – sudodus Aug 05 '22 at 07:05