rsync --update with symlinks

The name of the pictureThe name of the pictureThe name of the pictureClash 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.







share|improve this question























    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.







    share|improve this question





















      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.







      share|improve this question











      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.









      share|improve this question










      share|improve this question




      share|improve this question









      asked May 27 at 23:00









      Kevin

      1185




      1185




















          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





          share|improve this answer





















          • 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










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          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






























          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





          share|improve this answer





















          • 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














          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





          share|improve this answer





















          • 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












          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





          share|improve this answer













          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






          share|improve this answer













          share|improve this answer



          share|improve this answer











          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
















          • 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












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          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













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?