How to tell rsync not to delete some folders at destination?












4















So I use pelican for writing my blog and I upload the whole thing using rsync. OK.



But I use also Let's Encrypt and therefor need the repository .well-known preserved at the root of my website.



So is there a way I can say "rsync ... --do-not-delete .well-known ..."



Currently, those rep' are permission protected, but rsync doesn't like it.



Here is the current rsync command (installed by pelican itself, I did not write it) :



rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --delete $(OUTPUTDIR)/ $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR) --cvs-exclude


BTW : if you have also some suggestion to improve rsync efficiency, I take it (yes, it's off topic).










share|improve this question



























    4















    So I use pelican for writing my blog and I upload the whole thing using rsync. OK.



    But I use also Let's Encrypt and therefor need the repository .well-known preserved at the root of my website.



    So is there a way I can say "rsync ... --do-not-delete .well-known ..."



    Currently, those rep' are permission protected, but rsync doesn't like it.



    Here is the current rsync command (installed by pelican itself, I did not write it) :



    rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --delete $(OUTPUTDIR)/ $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR) --cvs-exclude


    BTW : if you have also some suggestion to improve rsync efficiency, I take it (yes, it's off topic).










    share|improve this question

























      4












      4








      4








      So I use pelican for writing my blog and I upload the whole thing using rsync. OK.



      But I use also Let's Encrypt and therefor need the repository .well-known preserved at the root of my website.



      So is there a way I can say "rsync ... --do-not-delete .well-known ..."



      Currently, those rep' are permission protected, but rsync doesn't like it.



      Here is the current rsync command (installed by pelican itself, I did not write it) :



      rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --delete $(OUTPUTDIR)/ $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR) --cvs-exclude


      BTW : if you have also some suggestion to improve rsync efficiency, I take it (yes, it's off topic).










      share|improve this question














      So I use pelican for writing my blog and I upload the whole thing using rsync. OK.



      But I use also Let's Encrypt and therefor need the repository .well-known preserved at the root of my website.



      So is there a way I can say "rsync ... --do-not-delete .well-known ..."



      Currently, those rep' are permission protected, but rsync doesn't like it.



      Here is the current rsync command (installed by pelican itself, I did not write it) :



      rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --delete $(OUTPUTDIR)/ $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR) --cvs-exclude


      BTW : if you have also some suggestion to improve rsync efficiency, I take it (yes, it's off topic).







      rsync






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Apr 23 '16 at 10:22









      22decembre22decembre

      96119




      96119






















          2 Answers
          2






          active

          oldest

          votes


















          6














          From man rsync




          --delete
          This tells rsync to delete extraneous files from the receiving
          side (ones that aren’t on the sending side), but only for the
          directories that are being synchronized. You must have asked
          rsync to send the whole directory (e.g. "dir" or "dir/") without
          using a wildcard for the directory’s contents (e.g. "dir/*")
          since the wildcard is expanded by the shell and rsync thus gets
          a request to transfer individual files, not the files’ parent
          directory. Files that are excluded from the transfer are also
          excluded from being deleted unless you use the --delete-excluded
          option or mark the rules as only matching on the sending side

          (see the include/exclude modifiers in the FILTER RULES section).




          So I think it should be



          rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --delete 
          $(OUTPUTDIR)/
          $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)
          --cvs-exclude --exclude=/.well-known


          (assuming .well-known is at the root of $(SSH_TARGET_DIR)/)






          share|improve this answer

































            4














            You should use the --exclude option in order to make rsync ignore that directory. Unless you also use --delete-excluded (which you shouldn't, in this case), it will leave it alone.






            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%2f278561%2fhow-to-tell-rsync-not-to-delete-some-folders-at-destination%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









              6














              From man rsync




              --delete
              This tells rsync to delete extraneous files from the receiving
              side (ones that aren’t on the sending side), but only for the
              directories that are being synchronized. You must have asked
              rsync to send the whole directory (e.g. "dir" or "dir/") without
              using a wildcard for the directory’s contents (e.g. "dir/*")
              since the wildcard is expanded by the shell and rsync thus gets
              a request to transfer individual files, not the files’ parent
              directory. Files that are excluded from the transfer are also
              excluded from being deleted unless you use the --delete-excluded
              option or mark the rules as only matching on the sending side

              (see the include/exclude modifiers in the FILTER RULES section).




              So I think it should be



              rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --delete 
              $(OUTPUTDIR)/
              $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)
              --cvs-exclude --exclude=/.well-known


              (assuming .well-known is at the root of $(SSH_TARGET_DIR)/)






              share|improve this answer






























                6














                From man rsync




                --delete
                This tells rsync to delete extraneous files from the receiving
                side (ones that aren’t on the sending side), but only for the
                directories that are being synchronized. You must have asked
                rsync to send the whole directory (e.g. "dir" or "dir/") without
                using a wildcard for the directory’s contents (e.g. "dir/*")
                since the wildcard is expanded by the shell and rsync thus gets
                a request to transfer individual files, not the files’ parent
                directory. Files that are excluded from the transfer are also
                excluded from being deleted unless you use the --delete-excluded
                option or mark the rules as only matching on the sending side

                (see the include/exclude modifiers in the FILTER RULES section).




                So I think it should be



                rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --delete 
                $(OUTPUTDIR)/
                $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)
                --cvs-exclude --exclude=/.well-known


                (assuming .well-known is at the root of $(SSH_TARGET_DIR)/)






                share|improve this answer




























                  6












                  6








                  6







                  From man rsync




                  --delete
                  This tells rsync to delete extraneous files from the receiving
                  side (ones that aren’t on the sending side), but only for the
                  directories that are being synchronized. You must have asked
                  rsync to send the whole directory (e.g. "dir" or "dir/") without
                  using a wildcard for the directory’s contents (e.g. "dir/*")
                  since the wildcard is expanded by the shell and rsync thus gets
                  a request to transfer individual files, not the files’ parent
                  directory. Files that are excluded from the transfer are also
                  excluded from being deleted unless you use the --delete-excluded
                  option or mark the rules as only matching on the sending side

                  (see the include/exclude modifiers in the FILTER RULES section).




                  So I think it should be



                  rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --delete 
                  $(OUTPUTDIR)/
                  $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)
                  --cvs-exclude --exclude=/.well-known


                  (assuming .well-known is at the root of $(SSH_TARGET_DIR)/)






                  share|improve this answer















                  From man rsync




                  --delete
                  This tells rsync to delete extraneous files from the receiving
                  side (ones that aren’t on the sending side), but only for the
                  directories that are being synchronized. You must have asked
                  rsync to send the whole directory (e.g. "dir" or "dir/") without
                  using a wildcard for the directory’s contents (e.g. "dir/*")
                  since the wildcard is expanded by the shell and rsync thus gets
                  a request to transfer individual files, not the files’ parent
                  directory. Files that are excluded from the transfer are also
                  excluded from being deleted unless you use the --delete-excluded
                  option or mark the rules as only matching on the sending side

                  (see the include/exclude modifiers in the FILTER RULES section).




                  So I think it should be



                  rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --delete 
                  $(OUTPUTDIR)/
                  $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)
                  --cvs-exclude --exclude=/.well-known


                  (assuming .well-known is at the root of $(SSH_TARGET_DIR)/)







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Feb 19 at 18:43









                  fdehanne

                  1156




                  1156










                  answered Apr 23 '16 at 14:15









                  Hai Luong DongHai Luong Dong

                  13115




                  13115

























                      4














                      You should use the --exclude option in order to make rsync ignore that directory. Unless you also use --delete-excluded (which you shouldn't, in this case), it will leave it alone.






                      share|improve this answer




























                        4














                        You should use the --exclude option in order to make rsync ignore that directory. Unless you also use --delete-excluded (which you shouldn't, in this case), it will leave it alone.






                        share|improve this answer


























                          4












                          4








                          4







                          You should use the --exclude option in order to make rsync ignore that directory. Unless you also use --delete-excluded (which you shouldn't, in this case), it will leave it alone.






                          share|improve this answer













                          You should use the --exclude option in order to make rsync ignore that directory. Unless you also use --delete-excluded (which you shouldn't, in this case), it will leave it alone.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Apr 23 '16 at 12:21









                          CeladaCelada

                          31k46584




                          31k46584






























                              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%2f278561%2fhow-to-tell-rsync-not-to-delete-some-folders-at-destination%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

                              How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

                              is 'sed' thread safe

                              How to make a Squid Proxy server?