Can rsync be configured to avoid modifying subdirectories not found in the source folder? ...

If my PI received research grants from a company to be able to pay my postdoc salary, did I have a potential conflict interest too?

How to answer "Have you ever been terminated?"

Why are both D and D# fitting into my E minor key?

Is the Standard Deduction better than Itemized when both are the same amount?

Does classifying an integer as a discrete log require it be part of a multiplicative group?

How to tell that you are a giant?

Closed form of recurrent arithmetic series summation

What is the meaning of the simile “quick as silk”?

How do pianists reach extremely loud dynamics?

Why wasn't DOSKEY integrated with COMMAND.COM?

Can a party unilaterally change candidates in preparation for a General election?

Do I really need to have a message in a novel to appeal to readers?

What does this Jacques Hadamard quote mean?

Is there a holomorphic function on open unit disc with this property?

Can you use the Shield Master feat to shove someone before you make an attack by using a Readied action?

Maximum summed powersets with non-adjacent items

Quick way to create a symlink?

Declining "dulcis" in context

How to Make a Beautiful Stacked 3D Plot

What is homebrew?

How to compare two different files line by line in unix?

How to down pick a chord with skipped strings?

How would a mousetrap for use in space work?

Is safe to use va_start macro with this as parameter?



Can rsync be configured to avoid modifying subdirectories not found in the source folder?



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionrsync all directories that start with a specific digitRsync from multiple folders to oneUsing rsync, how can I know what attribute of source file differed from the dest which caused the trasferrsync option to exclude partial filesrsync question syncing source with destination (archiving surplus files on destination)rsync command does incremental copying or overwrites the file?rsync only files newer than given date, with --deleteDoes the delta-transfer algorithm used in rsync transfer part of a source file, i.e. subfile?rsync + chmod multiple filesrecursively sync only specific files from specific subdirectories from a remote server





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















I am having a hard time figuring out exactly how to run rsync to get it to do what I need it to do. Basically what I need is as follows given a single source folder with multiple sub-directories:



-If files for a given subdirectory are changed in the source folder, sync those changes to the destination (update files and delete files not found in the source folder any longer).



-If a folder is found in the source but not the destination, sync the folder and all of its contents to the destination.



-If a folder is found in the destination but not in the source, do nothing (e.g. don't delete it).



This is what the directory structure would look like:



Source Folder
Folder 1
File 1 unchanged.txt
Folder 2
File 2 newer.txt
Folder 3
File 3.txt

Destination Folder
Folder 1
File 1 unchanged.txt
Folder 2
File 2 old.txt (to be replaced with File 2 newer.txt)
(Folder 3 not yet in destination, to be added from source)
Folder X (not in source, to be left untouched)









share|improve this question































    1















    I am having a hard time figuring out exactly how to run rsync to get it to do what I need it to do. Basically what I need is as follows given a single source folder with multiple sub-directories:



    -If files for a given subdirectory are changed in the source folder, sync those changes to the destination (update files and delete files not found in the source folder any longer).



    -If a folder is found in the source but not the destination, sync the folder and all of its contents to the destination.



    -If a folder is found in the destination but not in the source, do nothing (e.g. don't delete it).



    This is what the directory structure would look like:



    Source Folder
    Folder 1
    File 1 unchanged.txt
    Folder 2
    File 2 newer.txt
    Folder 3
    File 3.txt

    Destination Folder
    Folder 1
    File 1 unchanged.txt
    Folder 2
    File 2 old.txt (to be replaced with File 2 newer.txt)
    (Folder 3 not yet in destination, to be added from source)
    Folder X (not in source, to be left untouched)









    share|improve this question



























      1












      1








      1








      I am having a hard time figuring out exactly how to run rsync to get it to do what I need it to do. Basically what I need is as follows given a single source folder with multiple sub-directories:



      -If files for a given subdirectory are changed in the source folder, sync those changes to the destination (update files and delete files not found in the source folder any longer).



      -If a folder is found in the source but not the destination, sync the folder and all of its contents to the destination.



      -If a folder is found in the destination but not in the source, do nothing (e.g. don't delete it).



      This is what the directory structure would look like:



      Source Folder
      Folder 1
      File 1 unchanged.txt
      Folder 2
      File 2 newer.txt
      Folder 3
      File 3.txt

      Destination Folder
      Folder 1
      File 1 unchanged.txt
      Folder 2
      File 2 old.txt (to be replaced with File 2 newer.txt)
      (Folder 3 not yet in destination, to be added from source)
      Folder X (not in source, to be left untouched)









      share|improve this question
















      I am having a hard time figuring out exactly how to run rsync to get it to do what I need it to do. Basically what I need is as follows given a single source folder with multiple sub-directories:



      -If files for a given subdirectory are changed in the source folder, sync those changes to the destination (update files and delete files not found in the source folder any longer).



      -If a folder is found in the source but not the destination, sync the folder and all of its contents to the destination.



      -If a folder is found in the destination but not in the source, do nothing (e.g. don't delete it).



      This is what the directory structure would look like:



      Source Folder
      Folder 1
      File 1 unchanged.txt
      Folder 2
      File 2 newer.txt
      Folder 3
      File 3.txt

      Destination Folder
      Folder 1
      File 1 unchanged.txt
      Folder 2
      File 2 old.txt (to be replaced with File 2 newer.txt)
      (Folder 3 not yet in destination, to be added from source)
      Folder X (not in source, to be left untouched)






      rsync






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 27 '14 at 22:20









      Braiam

      23.8k2078144




      23.8k2078144










      asked Oct 27 '14 at 21:18









      Ian KIan K

      62




      62






















          2 Answers
          2






          active

          oldest

          votes


















          0














          According to man rsync you can use:



          --exclude=PATTERN


          Or your list is too large you can use :



          --exclude-from=FILE 





          share|improve this answer


























          • This has nothing to do with the question.

            – Gilles
            Oct 28 '14 at 23:46



















          0














          What you describe is the default standard behavior for rsync.



          If you wanted a different behavior you would have to use one of the --delete options.



          This is a test that proves my point:



           $ mkdir tmp1
          $ mkdir tmp2
          $ mkdir tmp1/1
          $ mkdir tmp1/2
          $ mkdir tmp2/1
          $ mkdir tmp2/X
          $ touch tmp1/1/1.txt
          $ touch tmp1/2/2.txt
          $ rsync -avz tmp1 tmp2
          sending incremental file list
          tmp1/
          tmp1/1/
          tmp1/1/1.txt
          tmp1/2/
          tmp1/2/2.txt

          sent 208 bytes received 62 bytes 540.00 bytes/sec
          total size is 0 speedup is 0.00
          $ ls tmp2
          1 tmp1 X


          You can see that directory X is there, untouched.



          If you are using it as a daemon, maybe your rsync is applying options from a config file.



          Look at /etc/rsyncd.conf to see if any delete options are set there or at rsyncd.conf at the home directory of the user that is launching the rsync






          share|improve this answer


























            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',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            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%2f164518%2fcan-rsync-be-configured-to-avoid-modifying-subdirectories-not-found-in-the-sourc%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            According to man rsync you can use:



            --exclude=PATTERN


            Or your list is too large you can use :



            --exclude-from=FILE 





            share|improve this answer


























            • This has nothing to do with the question.

              – Gilles
              Oct 28 '14 at 23:46
















            0














            According to man rsync you can use:



            --exclude=PATTERN


            Or your list is too large you can use :



            --exclude-from=FILE 





            share|improve this answer


























            • This has nothing to do with the question.

              – Gilles
              Oct 28 '14 at 23:46














            0












            0








            0







            According to man rsync you can use:



            --exclude=PATTERN


            Or your list is too large you can use :



            --exclude-from=FILE 





            share|improve this answer















            According to man rsync you can use:



            --exclude=PATTERN


            Or your list is too large you can use :



            --exclude-from=FILE 






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Oct 27 '14 at 22:45

























            answered Oct 27 '14 at 22:21









            PersianGulfPersianGulf

            7,07843663




            7,07843663













            • This has nothing to do with the question.

              – Gilles
              Oct 28 '14 at 23:46



















            • This has nothing to do with the question.

              – Gilles
              Oct 28 '14 at 23:46

















            This has nothing to do with the question.

            – Gilles
            Oct 28 '14 at 23:46





            This has nothing to do with the question.

            – Gilles
            Oct 28 '14 at 23:46













            0














            What you describe is the default standard behavior for rsync.



            If you wanted a different behavior you would have to use one of the --delete options.



            This is a test that proves my point:



             $ mkdir tmp1
            $ mkdir tmp2
            $ mkdir tmp1/1
            $ mkdir tmp1/2
            $ mkdir tmp2/1
            $ mkdir tmp2/X
            $ touch tmp1/1/1.txt
            $ touch tmp1/2/2.txt
            $ rsync -avz tmp1 tmp2
            sending incremental file list
            tmp1/
            tmp1/1/
            tmp1/1/1.txt
            tmp1/2/
            tmp1/2/2.txt

            sent 208 bytes received 62 bytes 540.00 bytes/sec
            total size is 0 speedup is 0.00
            $ ls tmp2
            1 tmp1 X


            You can see that directory X is there, untouched.



            If you are using it as a daemon, maybe your rsync is applying options from a config file.



            Look at /etc/rsyncd.conf to see if any delete options are set there or at rsyncd.conf at the home directory of the user that is launching the rsync






            share|improve this answer






























              0














              What you describe is the default standard behavior for rsync.



              If you wanted a different behavior you would have to use one of the --delete options.



              This is a test that proves my point:



               $ mkdir tmp1
              $ mkdir tmp2
              $ mkdir tmp1/1
              $ mkdir tmp1/2
              $ mkdir tmp2/1
              $ mkdir tmp2/X
              $ touch tmp1/1/1.txt
              $ touch tmp1/2/2.txt
              $ rsync -avz tmp1 tmp2
              sending incremental file list
              tmp1/
              tmp1/1/
              tmp1/1/1.txt
              tmp1/2/
              tmp1/2/2.txt

              sent 208 bytes received 62 bytes 540.00 bytes/sec
              total size is 0 speedup is 0.00
              $ ls tmp2
              1 tmp1 X


              You can see that directory X is there, untouched.



              If you are using it as a daemon, maybe your rsync is applying options from a config file.



              Look at /etc/rsyncd.conf to see if any delete options are set there or at rsyncd.conf at the home directory of the user that is launching the rsync






              share|improve this answer




























                0












                0








                0







                What you describe is the default standard behavior for rsync.



                If you wanted a different behavior you would have to use one of the --delete options.



                This is a test that proves my point:



                 $ mkdir tmp1
                $ mkdir tmp2
                $ mkdir tmp1/1
                $ mkdir tmp1/2
                $ mkdir tmp2/1
                $ mkdir tmp2/X
                $ touch tmp1/1/1.txt
                $ touch tmp1/2/2.txt
                $ rsync -avz tmp1 tmp2
                sending incremental file list
                tmp1/
                tmp1/1/
                tmp1/1/1.txt
                tmp1/2/
                tmp1/2/2.txt

                sent 208 bytes received 62 bytes 540.00 bytes/sec
                total size is 0 speedup is 0.00
                $ ls tmp2
                1 tmp1 X


                You can see that directory X is there, untouched.



                If you are using it as a daemon, maybe your rsync is applying options from a config file.



                Look at /etc/rsyncd.conf to see if any delete options are set there or at rsyncd.conf at the home directory of the user that is launching the rsync






                share|improve this answer















                What you describe is the default standard behavior for rsync.



                If you wanted a different behavior you would have to use one of the --delete options.



                This is a test that proves my point:



                 $ mkdir tmp1
                $ mkdir tmp2
                $ mkdir tmp1/1
                $ mkdir tmp1/2
                $ mkdir tmp2/1
                $ mkdir tmp2/X
                $ touch tmp1/1/1.txt
                $ touch tmp1/2/2.txt
                $ rsync -avz tmp1 tmp2
                sending incremental file list
                tmp1/
                tmp1/1/
                tmp1/1/1.txt
                tmp1/2/
                tmp1/2/2.txt

                sent 208 bytes received 62 bytes 540.00 bytes/sec
                total size is 0 speedup is 0.00
                $ ls tmp2
                1 tmp1 X


                You can see that directory X is there, untouched.



                If you are using it as a daemon, maybe your rsync is applying options from a config file.



                Look at /etc/rsyncd.conf to see if any delete options are set there or at rsyncd.conf at the home directory of the user that is launching the rsync







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 5 hours ago









                Rui F Ribeiro

                42.1k1484142




                42.1k1484142










                answered Oct 29 '14 at 17:21









                Luis Antolín CanoLuis Antolín Cano

                425311




                425311






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f164518%2fcan-rsync-be-configured-to-avoid-modifying-subdirectories-not-found-in-the-sourc%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Hudson River Historic District Contents Geography History The district today Aesthetics Cultural...

                    The number designs the writing. Feandra Aversely Definition: The act of ingrafting a sprig or shoot of one...

                    Ayherre Geografie Demografie Externe links Navigatiemenu43° 23′ NB, 1° 15′ WL43° 23′ NB, 1°...