Prevent rsync from deleting excluded directoriesCopying a large directory tree locally? cp or rsync?rsync...

What is the term when two people sing in harmony, but they aren't singing the same notes?

Why does this part of the Space Shuttle launch pad seem to be floating in air?

How will losing mobility of one hand affect my career as a programmer?

How to prevent YouTube from showing already watched videos?

How to deal with or prevent idle in the test team?

How do I repair my stair bannister?

How to color a zone in Tikz

Invariance of results when scaling explanatory variables in logistic regression, is there a proof?

Indicating multiple different modes of speech (fantasy language or telepathy)

What if somebody invests in my application?

Books on the History of math research at European universities

What is the opposite of 'gravitas'?

Female=gender counterpart?

Can a Bard use an arcane focus?

Meta programming: Declare a new struct on the fly

Should a half Jewish man be discouraged from marrying a Jewess?

Pronouncing Homer as in modern Greek

Why Were Madagascar and New Zealand Discovered So Late?

Who must act to prevent Brexit on March 29th?

Calculating the number of days between 2 dates in Excel

For airliners, what prevents wing strikes on landing in bad weather?

What does 사자 in this picture means?

Superhero words!

Do all polymers contain either carbon or silicon?



Prevent rsync from deleting excluded directories


Copying a large directory tree locally? cp or rsync?rsync backup keep deleted filesWhat is archive mode in rsync?Chunking large rsync transfers?Intermittent rsync over ssh errors via cron w/ Ubuntu 10.04: unexplained & protocol data streamWhat exactly will --delete-excluded do for rsync?DeltaCopy (Rsync for windows) giving an error on task runRsync Exclude RemotePrevent rsync from changing ctimeOnly downloading new folders/files with rsync













3















I'm using rsync through Ansible's synchronize-module with the following task definition:



synchronize: src='{{ local_app_path }}/.' dest='{{ remote_app_path }}/' perms=no owner=yes rsync_opts=--delete-after


Running this task generates the following command:



rsync --delay-updates -FF --compress --archive --no-perms --rsh 'ssh  -S none -o StrictHostKeyChecking=no' --rsync-path="sudo rsync" --delete-after --out-format='<<CHANGED>>%i %n%L' "../src/." "vagrant@192.168.55.55:/var/www/app/"


My directory layout goes like this:



src/
# ...
app/
test/
node_modules/
package.json
provisioning/
# ...
playbook.yml
.rsync-filter


This is my .rsync-filter:



exclude /src/.env
exclude /src/node_modules


Now I am expecting to run my synchronize-task and have the resulting directory-structure on the server look like this (notice the missing node_modules folder):



app/
test/
package.json


This works. However, once I create a node_modules folder on the server...



app/
test/
node_modules/
package.json


...and run the sync again, the node_modules-folder is deleted from the server again (even though I had excluded it in my .rsync-filter):



app/
test/
package.json


I am expecting the node_modules-folder to be kept on the server, because I have it listed in my .rsync-filter and am not using the --delete-excluded option.



How can I prevent my excluded files/directories from being deleted with rsync?



Thanks a lot for your help! :)










share|improve this question



























    3















    I'm using rsync through Ansible's synchronize-module with the following task definition:



    synchronize: src='{{ local_app_path }}/.' dest='{{ remote_app_path }}/' perms=no owner=yes rsync_opts=--delete-after


    Running this task generates the following command:



    rsync --delay-updates -FF --compress --archive --no-perms --rsh 'ssh  -S none -o StrictHostKeyChecking=no' --rsync-path="sudo rsync" --delete-after --out-format='<<CHANGED>>%i %n%L' "../src/." "vagrant@192.168.55.55:/var/www/app/"


    My directory layout goes like this:



    src/
    # ...
    app/
    test/
    node_modules/
    package.json
    provisioning/
    # ...
    playbook.yml
    .rsync-filter


    This is my .rsync-filter:



    exclude /src/.env
    exclude /src/node_modules


    Now I am expecting to run my synchronize-task and have the resulting directory-structure on the server look like this (notice the missing node_modules folder):



    app/
    test/
    package.json


    This works. However, once I create a node_modules folder on the server...



    app/
    test/
    node_modules/
    package.json


    ...and run the sync again, the node_modules-folder is deleted from the server again (even though I had excluded it in my .rsync-filter):



    app/
    test/
    package.json


    I am expecting the node_modules-folder to be kept on the server, because I have it listed in my .rsync-filter and am not using the --delete-excluded option.



    How can I prevent my excluded files/directories from being deleted with rsync?



    Thanks a lot for your help! :)










    share|improve this question

























      3












      3








      3








      I'm using rsync through Ansible's synchronize-module with the following task definition:



      synchronize: src='{{ local_app_path }}/.' dest='{{ remote_app_path }}/' perms=no owner=yes rsync_opts=--delete-after


      Running this task generates the following command:



      rsync --delay-updates -FF --compress --archive --no-perms --rsh 'ssh  -S none -o StrictHostKeyChecking=no' --rsync-path="sudo rsync" --delete-after --out-format='<<CHANGED>>%i %n%L' "../src/." "vagrant@192.168.55.55:/var/www/app/"


      My directory layout goes like this:



      src/
      # ...
      app/
      test/
      node_modules/
      package.json
      provisioning/
      # ...
      playbook.yml
      .rsync-filter


      This is my .rsync-filter:



      exclude /src/.env
      exclude /src/node_modules


      Now I am expecting to run my synchronize-task and have the resulting directory-structure on the server look like this (notice the missing node_modules folder):



      app/
      test/
      package.json


      This works. However, once I create a node_modules folder on the server...



      app/
      test/
      node_modules/
      package.json


      ...and run the sync again, the node_modules-folder is deleted from the server again (even though I had excluded it in my .rsync-filter):



      app/
      test/
      package.json


      I am expecting the node_modules-folder to be kept on the server, because I have it listed in my .rsync-filter and am not using the --delete-excluded option.



      How can I prevent my excluded files/directories from being deleted with rsync?



      Thanks a lot for your help! :)










      share|improve this question














      I'm using rsync through Ansible's synchronize-module with the following task definition:



      synchronize: src='{{ local_app_path }}/.' dest='{{ remote_app_path }}/' perms=no owner=yes rsync_opts=--delete-after


      Running this task generates the following command:



      rsync --delay-updates -FF --compress --archive --no-perms --rsh 'ssh  -S none -o StrictHostKeyChecking=no' --rsync-path="sudo rsync" --delete-after --out-format='<<CHANGED>>%i %n%L' "../src/." "vagrant@192.168.55.55:/var/www/app/"


      My directory layout goes like this:



      src/
      # ...
      app/
      test/
      node_modules/
      package.json
      provisioning/
      # ...
      playbook.yml
      .rsync-filter


      This is my .rsync-filter:



      exclude /src/.env
      exclude /src/node_modules


      Now I am expecting to run my synchronize-task and have the resulting directory-structure on the server look like this (notice the missing node_modules folder):



      app/
      test/
      package.json


      This works. However, once I create a node_modules folder on the server...



      app/
      test/
      node_modules/
      package.json


      ...and run the sync again, the node_modules-folder is deleted from the server again (even though I had excluded it in my .rsync-filter):



      app/
      test/
      package.json


      I am expecting the node_modules-folder to be kept on the server, because I have it listed in my .rsync-filter and am not using the --delete-excluded option.



      How can I prevent my excluded files/directories from being deleted with rsync?



      Thanks a lot for your help! :)







      unix rsync deployment ansible






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 8 '15 at 18:47









      MacksMacks

      1162




      1162






















          2 Answers
          2






          active

          oldest

          votes


















          0














          It's the -FF that is causing your problem. That stops the -rsync-filter file being copied across and as the rsync man page says ...



          MERGE-FILE FILTER RULES
          ...
          These per-directory rule files must be created on the sending side because it is the
          sending side that is being scanned for the available files to transfer. These rule files may also
          need to be transferred to the receiving side if you want them to affect what files don’t get deleted
          (see PER-DIRECTORY RULES AND DELETE below).


          Important bit is the last sentence in that quoted section. Changing -FF to -F gives desired behaviour.






          share|improve this answer































            0














            I have a very similar issue as the author of OP. So that's what I've found. But, however, I haven't tried it for myself yet. But it should work.



            TLDR: I think you need to add "--exclude=node_modules" to your rsync_opts in terms of Ansible.



            If you read rsync manual, you will see summary of these options



                        --delete                delete extraneous files from dest dirs
            --delete-before receiver deletes before xfer, not during
            --delete-during receiver deletes during the transfer
            --delete-delay find deletions during, delete after
            --delete-after receiver deletes after transfer, not during
            --delete-excluded also delete excluded files from dest dirs



            The option --delete-excluded is interesting.



            --delete-excluded
            In addition to deleting the files on the receiving side that
            are not on the sending side, this tells rsync to also delete
            any files on the receiving side that are excluded (see
            --exclude). See the FILTER RULES section for a way to make
            individual exclusions behave this way on the receiver, and for
            a way to protect files from --delete-excluded. See --delete
            (which is implied) for more details on file-deletion.


            but you don't actually need it, sure thing, except for that it references the --exclude option that you need.



            --exclude=PATTERN
            This option is a simplified form of the --filter option that
            defaults to an exclude rule and does not allow the full
            rule-parsing syntax of normal filter rules.

            See the FILTER RULES section for detailed information on this
            option.


            Add "--exclude=node_modules" to your rsync_opts.





            share








            New contributor




            konstunn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.




















              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "2"
              };
              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: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              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%2fserverfault.com%2fquestions%2f658195%2fprevent-rsync-from-deleting-excluded-directories%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














              It's the -FF that is causing your problem. That stops the -rsync-filter file being copied across and as the rsync man page says ...



              MERGE-FILE FILTER RULES
              ...
              These per-directory rule files must be created on the sending side because it is the
              sending side that is being scanned for the available files to transfer. These rule files may also
              need to be transferred to the receiving side if you want them to affect what files don’t get deleted
              (see PER-DIRECTORY RULES AND DELETE below).


              Important bit is the last sentence in that quoted section. Changing -FF to -F gives desired behaviour.






              share|improve this answer




























                0














                It's the -FF that is causing your problem. That stops the -rsync-filter file being copied across and as the rsync man page says ...



                MERGE-FILE FILTER RULES
                ...
                These per-directory rule files must be created on the sending side because it is the
                sending side that is being scanned for the available files to transfer. These rule files may also
                need to be transferred to the receiving side if you want them to affect what files don’t get deleted
                (see PER-DIRECTORY RULES AND DELETE below).


                Important bit is the last sentence in that quoted section. Changing -FF to -F gives desired behaviour.






                share|improve this answer


























                  0












                  0








                  0







                  It's the -FF that is causing your problem. That stops the -rsync-filter file being copied across and as the rsync man page says ...



                  MERGE-FILE FILTER RULES
                  ...
                  These per-directory rule files must be created on the sending side because it is the
                  sending side that is being scanned for the available files to transfer. These rule files may also
                  need to be transferred to the receiving side if you want them to affect what files don’t get deleted
                  (see PER-DIRECTORY RULES AND DELETE below).


                  Important bit is the last sentence in that quoted section. Changing -FF to -F gives desired behaviour.






                  share|improve this answer













                  It's the -FF that is causing your problem. That stops the -rsync-filter file being copied across and as the rsync man page says ...



                  MERGE-FILE FILTER RULES
                  ...
                  These per-directory rule files must be created on the sending side because it is the
                  sending side that is being scanned for the available files to transfer. These rule files may also
                  need to be transferred to the receiving side if you want them to affect what files don’t get deleted
                  (see PER-DIRECTORY RULES AND DELETE below).


                  Important bit is the last sentence in that quoted section. Changing -FF to -F gives desired behaviour.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 8 '15 at 22:28









                  Paul HaldanePaul Haldane

                  3,90211429




                  3,90211429

























                      0














                      I have a very similar issue as the author of OP. So that's what I've found. But, however, I haven't tried it for myself yet. But it should work.



                      TLDR: I think you need to add "--exclude=node_modules" to your rsync_opts in terms of Ansible.



                      If you read rsync manual, you will see summary of these options



                                  --delete                delete extraneous files from dest dirs
                      --delete-before receiver deletes before xfer, not during
                      --delete-during receiver deletes during the transfer
                      --delete-delay find deletions during, delete after
                      --delete-after receiver deletes after transfer, not during
                      --delete-excluded also delete excluded files from dest dirs



                      The option --delete-excluded is interesting.



                      --delete-excluded
                      In addition to deleting the files on the receiving side that
                      are not on the sending side, this tells rsync to also delete
                      any files on the receiving side that are excluded (see
                      --exclude). See the FILTER RULES section for a way to make
                      individual exclusions behave this way on the receiver, and for
                      a way to protect files from --delete-excluded. See --delete
                      (which is implied) for more details on file-deletion.


                      but you don't actually need it, sure thing, except for that it references the --exclude option that you need.



                      --exclude=PATTERN
                      This option is a simplified form of the --filter option that
                      defaults to an exclude rule and does not allow the full
                      rule-parsing syntax of normal filter rules.

                      See the FILTER RULES section for detailed information on this
                      option.


                      Add "--exclude=node_modules" to your rsync_opts.





                      share








                      New contributor




                      konstunn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.

























                        0














                        I have a very similar issue as the author of OP. So that's what I've found. But, however, I haven't tried it for myself yet. But it should work.



                        TLDR: I think you need to add "--exclude=node_modules" to your rsync_opts in terms of Ansible.



                        If you read rsync manual, you will see summary of these options



                                    --delete                delete extraneous files from dest dirs
                        --delete-before receiver deletes before xfer, not during
                        --delete-during receiver deletes during the transfer
                        --delete-delay find deletions during, delete after
                        --delete-after receiver deletes after transfer, not during
                        --delete-excluded also delete excluded files from dest dirs



                        The option --delete-excluded is interesting.



                        --delete-excluded
                        In addition to deleting the files on the receiving side that
                        are not on the sending side, this tells rsync to also delete
                        any files on the receiving side that are excluded (see
                        --exclude). See the FILTER RULES section for a way to make
                        individual exclusions behave this way on the receiver, and for
                        a way to protect files from --delete-excluded. See --delete
                        (which is implied) for more details on file-deletion.


                        but you don't actually need it, sure thing, except for that it references the --exclude option that you need.



                        --exclude=PATTERN
                        This option is a simplified form of the --filter option that
                        defaults to an exclude rule and does not allow the full
                        rule-parsing syntax of normal filter rules.

                        See the FILTER RULES section for detailed information on this
                        option.


                        Add "--exclude=node_modules" to your rsync_opts.





                        share








                        New contributor




                        konstunn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.























                          0












                          0








                          0







                          I have a very similar issue as the author of OP. So that's what I've found. But, however, I haven't tried it for myself yet. But it should work.



                          TLDR: I think you need to add "--exclude=node_modules" to your rsync_opts in terms of Ansible.



                          If you read rsync manual, you will see summary of these options



                                      --delete                delete extraneous files from dest dirs
                          --delete-before receiver deletes before xfer, not during
                          --delete-during receiver deletes during the transfer
                          --delete-delay find deletions during, delete after
                          --delete-after receiver deletes after transfer, not during
                          --delete-excluded also delete excluded files from dest dirs



                          The option --delete-excluded is interesting.



                          --delete-excluded
                          In addition to deleting the files on the receiving side that
                          are not on the sending side, this tells rsync to also delete
                          any files on the receiving side that are excluded (see
                          --exclude). See the FILTER RULES section for a way to make
                          individual exclusions behave this way on the receiver, and for
                          a way to protect files from --delete-excluded. See --delete
                          (which is implied) for more details on file-deletion.


                          but you don't actually need it, sure thing, except for that it references the --exclude option that you need.



                          --exclude=PATTERN
                          This option is a simplified form of the --filter option that
                          defaults to an exclude rule and does not allow the full
                          rule-parsing syntax of normal filter rules.

                          See the FILTER RULES section for detailed information on this
                          option.


                          Add "--exclude=node_modules" to your rsync_opts.





                          share








                          New contributor




                          konstunn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.










                          I have a very similar issue as the author of OP. So that's what I've found. But, however, I haven't tried it for myself yet. But it should work.



                          TLDR: I think you need to add "--exclude=node_modules" to your rsync_opts in terms of Ansible.



                          If you read rsync manual, you will see summary of these options



                                      --delete                delete extraneous files from dest dirs
                          --delete-before receiver deletes before xfer, not during
                          --delete-during receiver deletes during the transfer
                          --delete-delay find deletions during, delete after
                          --delete-after receiver deletes after transfer, not during
                          --delete-excluded also delete excluded files from dest dirs



                          The option --delete-excluded is interesting.



                          --delete-excluded
                          In addition to deleting the files on the receiving side that
                          are not on the sending side, this tells rsync to also delete
                          any files on the receiving side that are excluded (see
                          --exclude). See the FILTER RULES section for a way to make
                          individual exclusions behave this way on the receiver, and for
                          a way to protect files from --delete-excluded. See --delete
                          (which is implied) for more details on file-deletion.


                          but you don't actually need it, sure thing, except for that it references the --exclude option that you need.



                          --exclude=PATTERN
                          This option is a simplified form of the --filter option that
                          defaults to an exclude rule and does not allow the full
                          rule-parsing syntax of normal filter rules.

                          See the FILTER RULES section for detailed information on this
                          option.


                          Add "--exclude=node_modules" to your rsync_opts.






                          share








                          New contributor




                          konstunn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.








                          share


                          share






                          New contributor




                          konstunn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          answered 6 mins ago









                          konstunnkonstunn

                          11




                          11




                          New contributor




                          konstunn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.





                          New contributor





                          konstunn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.






                          konstunn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Server Fault!


                              • 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%2fserverfault.com%2fquestions%2f658195%2fprevent-rsync-from-deleting-excluded-directories%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

                              As a Security Precaution, the user account has been locked The Next CEO of Stack OverflowMS...

                              Українські прізвища Зміст Історичні відомості |...

                              Список ссавців Італії Природоохоронні статуси | Список |...