rsync --update with symlinks
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
This is related to this question but I don't think the answer exactly applies here.
I have two servers that sync directories between each other. These directories contain files and symlinks. On server B, I sync from server A with this command: rsync -auv A:dir/ dir/
What I want: Any file or symlink on A that is different and newer than the corresponding file or symlink on B is synced.
What actually happens: Any file on A that is different and newer than the corresponding file on B is synced. Any symlink on A that is different than the corresponding symlink on B is synced, regardless of timestamp.
The man page for rsync
has this (emphasis mine):
-u, --update
This forces rsync to skip any files which exist on the destination and have a modified time that is newer than the source file. (If an existing destination file has a modification time equal to the source file's, it will be updated if the sizes are different.) Note that this does not affect the copying of symlinks or other special files.
So this is the expected behavior. Why is this? Is there a way around it? Or, is there an alternate solution to the overall goal, which is to get these directories in sync after a server has been offline for some time and missed data?
My rsync version is 3.0.9
.
Example: I set up 2 directories, Adir
and Bdir
, each containing a file and a symlink with different contents:
$ ls -l Adir/ Bdir/
Adir/:
total 0
-rw-r--r-- 1 kevin kevin 5 May 27 18:00 file
lrwxrwxrwx 1 kevin kevin 10 May 27 18:00 symlink -> /some/file
Bdir/:
total 0
-rw-r--r-- 1 kevin kevin 6 May 27 17:00 file
lrwxrwxrwx 1 kevin kevin 16 May 27 17:00 symlink -> /some/other/file
Running rsync --dry-run -auv Adir/ Bdir/
outputs this:
sending incremental file list
./
file
symlink -> /some/file
sent 101 bytes received 21 bytes 244.00 bytes/sec
total size is 15 speedup is 0.12 (DRY RUN)
Which is what I expect. It copies (or would if not in dry run) both the file and symlink because they are newer. However running rsync --dry-run -auv Bdir/ Adir/
outputs this:
sending incremental file list
./
symlink -> /some/other/file
sent 104 bytes received 18 bytes 244.00 bytes/sec
total size is 22 speedup is 0.18 (DRY RUN)
Even though Bdir/symlink
is older than Adir/symlink
it still gets syned.
rsync symlink
add a comment |Â
up vote
0
down vote
favorite
This is related to this question but I don't think the answer exactly applies here.
I have two servers that sync directories between each other. These directories contain files and symlinks. On server B, I sync from server A with this command: rsync -auv A:dir/ dir/
What I want: Any file or symlink on A that is different and newer than the corresponding file or symlink on B is synced.
What actually happens: Any file on A that is different and newer than the corresponding file on B is synced. Any symlink on A that is different than the corresponding symlink on B is synced, regardless of timestamp.
The man page for rsync
has this (emphasis mine):
-u, --update
This forces rsync to skip any files which exist on the destination and have a modified time that is newer than the source file. (If an existing destination file has a modification time equal to the source file's, it will be updated if the sizes are different.) Note that this does not affect the copying of symlinks or other special files.
So this is the expected behavior. Why is this? Is there a way around it? Or, is there an alternate solution to the overall goal, which is to get these directories in sync after a server has been offline for some time and missed data?
My rsync version is 3.0.9
.
Example: I set up 2 directories, Adir
and Bdir
, each containing a file and a symlink with different contents:
$ ls -l Adir/ Bdir/
Adir/:
total 0
-rw-r--r-- 1 kevin kevin 5 May 27 18:00 file
lrwxrwxrwx 1 kevin kevin 10 May 27 18:00 symlink -> /some/file
Bdir/:
total 0
-rw-r--r-- 1 kevin kevin 6 May 27 17:00 file
lrwxrwxrwx 1 kevin kevin 16 May 27 17:00 symlink -> /some/other/file
Running rsync --dry-run -auv Adir/ Bdir/
outputs this:
sending incremental file list
./
file
symlink -> /some/file
sent 101 bytes received 21 bytes 244.00 bytes/sec
total size is 15 speedup is 0.12 (DRY RUN)
Which is what I expect. It copies (or would if not in dry run) both the file and symlink because they are newer. However running rsync --dry-run -auv Bdir/ Adir/
outputs this:
sending incremental file list
./
symlink -> /some/other/file
sent 104 bytes received 18 bytes 244.00 bytes/sec
total size is 22 speedup is 0.18 (DRY RUN)
Even though Bdir/symlink
is older than Adir/symlink
it still gets syned.
rsync symlink
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This is related to this question but I don't think the answer exactly applies here.
I have two servers that sync directories between each other. These directories contain files and symlinks. On server B, I sync from server A with this command: rsync -auv A:dir/ dir/
What I want: Any file or symlink on A that is different and newer than the corresponding file or symlink on B is synced.
What actually happens: Any file on A that is different and newer than the corresponding file on B is synced. Any symlink on A that is different than the corresponding symlink on B is synced, regardless of timestamp.
The man page for rsync
has this (emphasis mine):
-u, --update
This forces rsync to skip any files which exist on the destination and have a modified time that is newer than the source file. (If an existing destination file has a modification time equal to the source file's, it will be updated if the sizes are different.) Note that this does not affect the copying of symlinks or other special files.
So this is the expected behavior. Why is this? Is there a way around it? Or, is there an alternate solution to the overall goal, which is to get these directories in sync after a server has been offline for some time and missed data?
My rsync version is 3.0.9
.
Example: I set up 2 directories, Adir
and Bdir
, each containing a file and a symlink with different contents:
$ ls -l Adir/ Bdir/
Adir/:
total 0
-rw-r--r-- 1 kevin kevin 5 May 27 18:00 file
lrwxrwxrwx 1 kevin kevin 10 May 27 18:00 symlink -> /some/file
Bdir/:
total 0
-rw-r--r-- 1 kevin kevin 6 May 27 17:00 file
lrwxrwxrwx 1 kevin kevin 16 May 27 17:00 symlink -> /some/other/file
Running rsync --dry-run -auv Adir/ Bdir/
outputs this:
sending incremental file list
./
file
symlink -> /some/file
sent 101 bytes received 21 bytes 244.00 bytes/sec
total size is 15 speedup is 0.12 (DRY RUN)
Which is what I expect. It copies (or would if not in dry run) both the file and symlink because they are newer. However running rsync --dry-run -auv Bdir/ Adir/
outputs this:
sending incremental file list
./
symlink -> /some/other/file
sent 104 bytes received 18 bytes 244.00 bytes/sec
total size is 22 speedup is 0.18 (DRY RUN)
Even though Bdir/symlink
is older than Adir/symlink
it still gets syned.
rsync symlink
This is related to this question but I don't think the answer exactly applies here.
I have two servers that sync directories between each other. These directories contain files and symlinks. On server B, I sync from server A with this command: rsync -auv A:dir/ dir/
What I want: Any file or symlink on A that is different and newer than the corresponding file or symlink on B is synced.
What actually happens: Any file on A that is different and newer than the corresponding file on B is synced. Any symlink on A that is different than the corresponding symlink on B is synced, regardless of timestamp.
The man page for rsync
has this (emphasis mine):
-u, --update
This forces rsync to skip any files which exist on the destination and have a modified time that is newer than the source file. (If an existing destination file has a modification time equal to the source file's, it will be updated if the sizes are different.) Note that this does not affect the copying of symlinks or other special files.
So this is the expected behavior. Why is this? Is there a way around it? Or, is there an alternate solution to the overall goal, which is to get these directories in sync after a server has been offline for some time and missed data?
My rsync version is 3.0.9
.
Example: I set up 2 directories, Adir
and Bdir
, each containing a file and a symlink with different contents:
$ ls -l Adir/ Bdir/
Adir/:
total 0
-rw-r--r-- 1 kevin kevin 5 May 27 18:00 file
lrwxrwxrwx 1 kevin kevin 10 May 27 18:00 symlink -> /some/file
Bdir/:
total 0
-rw-r--r-- 1 kevin kevin 6 May 27 17:00 file
lrwxrwxrwx 1 kevin kevin 16 May 27 17:00 symlink -> /some/other/file
Running rsync --dry-run -auv Adir/ Bdir/
outputs this:
sending incremental file list
./
file
symlink -> /some/file
sent 101 bytes received 21 bytes 244.00 bytes/sec
total size is 15 speedup is 0.12 (DRY RUN)
Which is what I expect. It copies (or would if not in dry run) both the file and symlink because they are newer. However running rsync --dry-run -auv Bdir/ Adir/
outputs this:
sending incremental file list
./
symlink -> /some/other/file
sent 104 bytes received 18 bytes 244.00 bytes/sec
total size is 22 speedup is 0.18 (DRY RUN)
Even though Bdir/symlink
is older than Adir/symlink
it still gets syned.
rsync symlink
asked May 27 at 23:00
Kevin
1185
1185
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
One way out may be to ignore symlinks in rsync and do them separately with, for example, tar
which can be asked not to overwrite newer targets. Eg
( cd Adir; find . -type l |
tar cf - -T-
) |
tar xvvf - --keep-newer-files -C Bdir
This sounds like it would be a messy solution because the directories are on different servers. But I could probably work with this is there aren't any better options.
â Kevin
May 28 at 23:09
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
One way out may be to ignore symlinks in rsync and do them separately with, for example, tar
which can be asked not to overwrite newer targets. Eg
( cd Adir; find . -type l |
tar cf - -T-
) |
tar xvvf - --keep-newer-files -C Bdir
This sounds like it would be a messy solution because the directories are on different servers. But I could probably work with this is there aren't any better options.
â Kevin
May 28 at 23:09
add a comment |Â
up vote
1
down vote
One way out may be to ignore symlinks in rsync and do them separately with, for example, tar
which can be asked not to overwrite newer targets. Eg
( cd Adir; find . -type l |
tar cf - -T-
) |
tar xvvf - --keep-newer-files -C Bdir
This sounds like it would be a messy solution because the directories are on different servers. But I could probably work with this is there aren't any better options.
â Kevin
May 28 at 23:09
add a comment |Â
up vote
1
down vote
up vote
1
down vote
One way out may be to ignore symlinks in rsync and do them separately with, for example, tar
which can be asked not to overwrite newer targets. Eg
( cd Adir; find . -type l |
tar cf - -T-
) |
tar xvvf - --keep-newer-files -C Bdir
One way out may be to ignore symlinks in rsync and do them separately with, for example, tar
which can be asked not to overwrite newer targets. Eg
( cd Adir; find . -type l |
tar cf - -T-
) |
tar xvvf - --keep-newer-files -C Bdir
answered May 28 at 14:15
meuh
29.2k11648
29.2k11648
This sounds like it would be a messy solution because the directories are on different servers. But I could probably work with this is there aren't any better options.
â Kevin
May 28 at 23:09
add a comment |Â
This sounds like it would be a messy solution because the directories are on different servers. But I could probably work with this is there aren't any better options.
â Kevin
May 28 at 23:09
This sounds like it would be a messy solution because the directories are on different servers. But I could probably work with this is there aren't any better options.
â Kevin
May 28 at 23:09
This sounds like it would be a messy solution because the directories are on different servers. But I could probably work with this is there aren't any better options.
â Kevin
May 28 at 23:09
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f446369%2frsync-update-with-symlinks%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password