Can rsync copy directories over links

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I have the following scenario where I need to copy directories which sometimes can be links and sometimes a directory with the same name. For instance, suppose this is the initial setup:



Source:
/workspace/test/source/dir1 -> /tmp/test1



Destination:
/workspace/test/dest/dir1 -> /tmp/test1



Now, suppose I remove the link in the source and create a folder with the same name, so now it looks like this:



Source:
/workspace/test/source/dir1



Destination:
/workspace/test/dest/dir1 -> /tmp/test1



What I'd like to do now, is to use rsync to copy the actual folder and "overwrite" the link, so it would look like:



Source:
/workspace/test/source/dir1



Destination:
/workspace/test/dest/dir1



Is there any way to do it via rsync? I know that if I use the rsync one level above, ie /workspace/test/source, it will work. Unfortunetly, I have to use the lowest level rsync.



Appreciate your response.







share|improve this question























    up vote
    0
    down vote

    favorite












    I have the following scenario where I need to copy directories which sometimes can be links and sometimes a directory with the same name. For instance, suppose this is the initial setup:



    Source:
    /workspace/test/source/dir1 -> /tmp/test1



    Destination:
    /workspace/test/dest/dir1 -> /tmp/test1



    Now, suppose I remove the link in the source and create a folder with the same name, so now it looks like this:



    Source:
    /workspace/test/source/dir1



    Destination:
    /workspace/test/dest/dir1 -> /tmp/test1



    What I'd like to do now, is to use rsync to copy the actual folder and "overwrite" the link, so it would look like:



    Source:
    /workspace/test/source/dir1



    Destination:
    /workspace/test/dest/dir1



    Is there any way to do it via rsync? I know that if I use the rsync one level above, ie /workspace/test/source, it will work. Unfortunetly, I have to use the lowest level rsync.



    Appreciate your response.







    share|improve this question





















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have the following scenario where I need to copy directories which sometimes can be links and sometimes a directory with the same name. For instance, suppose this is the initial setup:



      Source:
      /workspace/test/source/dir1 -> /tmp/test1



      Destination:
      /workspace/test/dest/dir1 -> /tmp/test1



      Now, suppose I remove the link in the source and create a folder with the same name, so now it looks like this:



      Source:
      /workspace/test/source/dir1



      Destination:
      /workspace/test/dest/dir1 -> /tmp/test1



      What I'd like to do now, is to use rsync to copy the actual folder and "overwrite" the link, so it would look like:



      Source:
      /workspace/test/source/dir1



      Destination:
      /workspace/test/dest/dir1



      Is there any way to do it via rsync? I know that if I use the rsync one level above, ie /workspace/test/source, it will work. Unfortunetly, I have to use the lowest level rsync.



      Appreciate your response.







      share|improve this question











      I have the following scenario where I need to copy directories which sometimes can be links and sometimes a directory with the same name. For instance, suppose this is the initial setup:



      Source:
      /workspace/test/source/dir1 -> /tmp/test1



      Destination:
      /workspace/test/dest/dir1 -> /tmp/test1



      Now, suppose I remove the link in the source and create a folder with the same name, so now it looks like this:



      Source:
      /workspace/test/source/dir1



      Destination:
      /workspace/test/dest/dir1 -> /tmp/test1



      What I'd like to do now, is to use rsync to copy the actual folder and "overwrite" the link, so it would look like:



      Source:
      /workspace/test/source/dir1



      Destination:
      /workspace/test/dest/dir1



      Is there any way to do it via rsync? I know that if I use the rsync one level above, ie /workspace/test/source, it will work. Unfortunetly, I have to use the lowest level rsync.



      Appreciate your response.









      share|improve this question










      share|improve this question




      share|improve this question









      asked May 3 at 12:30









      Emil Gelman

      1




      1




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          This is the default behaviour of rsync.



          Example



          ## Preamble
          $ cd /tmp
          $ mkdir src dst stuff
          $ touch stuff/a,b,c
          $ ( cd src && ln -s /tmp/stuff dir1 )
          $ ( cd dst && ln -s /tmp/stuff dir1 )

          ## Symlinks are retained
          $ cd /tmp
          $ rsync -avv src/ dst/

          ## Change scenario
          $ ls -l src
          $ rm src/dir1 && cp -a /tmp/stuff src/dir1

          ## Symlinks are replaced according to the source
          $ cd /tmp
          $ rsync -avv src/ dst/
          $ ls -l dst





          share|improve this answer





















          • Thanks for the comment. My intention is to rsync src/dir1 dst/dir1. I know that in top level it works, but the problem is I have to use the lowest level directory.
            – Emil Gelman
            May 6 at 10:02











          • @Emil it can't work below the symlink because that's not part of the copy process
            – roaima
            May 6 at 14:20










          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%2f441534%2fcan-rsync-copy-directories-over-links%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
          0
          down vote













          This is the default behaviour of rsync.



          Example



          ## Preamble
          $ cd /tmp
          $ mkdir src dst stuff
          $ touch stuff/a,b,c
          $ ( cd src && ln -s /tmp/stuff dir1 )
          $ ( cd dst && ln -s /tmp/stuff dir1 )

          ## Symlinks are retained
          $ cd /tmp
          $ rsync -avv src/ dst/

          ## Change scenario
          $ ls -l src
          $ rm src/dir1 && cp -a /tmp/stuff src/dir1

          ## Symlinks are replaced according to the source
          $ cd /tmp
          $ rsync -avv src/ dst/
          $ ls -l dst





          share|improve this answer





















          • Thanks for the comment. My intention is to rsync src/dir1 dst/dir1. I know that in top level it works, but the problem is I have to use the lowest level directory.
            – Emil Gelman
            May 6 at 10:02











          • @Emil it can't work below the symlink because that's not part of the copy process
            – roaima
            May 6 at 14:20














          up vote
          0
          down vote













          This is the default behaviour of rsync.



          Example



          ## Preamble
          $ cd /tmp
          $ mkdir src dst stuff
          $ touch stuff/a,b,c
          $ ( cd src && ln -s /tmp/stuff dir1 )
          $ ( cd dst && ln -s /tmp/stuff dir1 )

          ## Symlinks are retained
          $ cd /tmp
          $ rsync -avv src/ dst/

          ## Change scenario
          $ ls -l src
          $ rm src/dir1 && cp -a /tmp/stuff src/dir1

          ## Symlinks are replaced according to the source
          $ cd /tmp
          $ rsync -avv src/ dst/
          $ ls -l dst





          share|improve this answer





















          • Thanks for the comment. My intention is to rsync src/dir1 dst/dir1. I know that in top level it works, but the problem is I have to use the lowest level directory.
            – Emil Gelman
            May 6 at 10:02











          • @Emil it can't work below the symlink because that's not part of the copy process
            – roaima
            May 6 at 14:20












          up vote
          0
          down vote










          up vote
          0
          down vote









          This is the default behaviour of rsync.



          Example



          ## Preamble
          $ cd /tmp
          $ mkdir src dst stuff
          $ touch stuff/a,b,c
          $ ( cd src && ln -s /tmp/stuff dir1 )
          $ ( cd dst && ln -s /tmp/stuff dir1 )

          ## Symlinks are retained
          $ cd /tmp
          $ rsync -avv src/ dst/

          ## Change scenario
          $ ls -l src
          $ rm src/dir1 && cp -a /tmp/stuff src/dir1

          ## Symlinks are replaced according to the source
          $ cd /tmp
          $ rsync -avv src/ dst/
          $ ls -l dst





          share|improve this answer













          This is the default behaviour of rsync.



          Example



          ## Preamble
          $ cd /tmp
          $ mkdir src dst stuff
          $ touch stuff/a,b,c
          $ ( cd src && ln -s /tmp/stuff dir1 )
          $ ( cd dst && ln -s /tmp/stuff dir1 )

          ## Symlinks are retained
          $ cd /tmp
          $ rsync -avv src/ dst/

          ## Change scenario
          $ ls -l src
          $ rm src/dir1 && cp -a /tmp/stuff src/dir1

          ## Symlinks are replaced according to the source
          $ cd /tmp
          $ rsync -avv src/ dst/
          $ ls -l dst






          share|improve this answer













          share|improve this answer



          share|improve this answer











          answered May 3 at 15:35









          roaima

          39.4k545106




          39.4k545106











          • Thanks for the comment. My intention is to rsync src/dir1 dst/dir1. I know that in top level it works, but the problem is I have to use the lowest level directory.
            – Emil Gelman
            May 6 at 10:02











          • @Emil it can't work below the symlink because that's not part of the copy process
            – roaima
            May 6 at 14:20
















          • Thanks for the comment. My intention is to rsync src/dir1 dst/dir1. I know that in top level it works, but the problem is I have to use the lowest level directory.
            – Emil Gelman
            May 6 at 10:02











          • @Emil it can't work below the symlink because that's not part of the copy process
            – roaima
            May 6 at 14:20















          Thanks for the comment. My intention is to rsync src/dir1 dst/dir1. I know that in top level it works, but the problem is I have to use the lowest level directory.
          – Emil Gelman
          May 6 at 10:02





          Thanks for the comment. My intention is to rsync src/dir1 dst/dir1. I know that in top level it works, but the problem is I have to use the lowest level directory.
          – Emil Gelman
          May 6 at 10:02













          @Emil it can't work below the symlink because that's not part of the copy process
          – roaima
          May 6 at 14:20




          @Emil it can't work below the symlink because that's not part of the copy process
          – roaima
          May 6 at 14:20












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f441534%2fcan-rsync-copy-directories-over-links%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?

          Christian Cage

          How to properly install USB display driver for Fresco Logic FL2000DX on Ubuntu?