rsync: delete except on one folderrsync verify a file already exists in dest folder so it will skip the copy...

Why do we have to make "peinlich" start with a capital letter and also end with -s in this sentence?

What game did these black and yellow dice come from?

Why zero tolerance on nudity in space?

A Missing Symbol for This Logo

Which communication protocol is used in AdLib sound card?

Square Root Distance from Integers

What is the difference between rolling more dice versus fewer dice?

Why avoid shared user accounts?

Is there any risk in sharing info about technologies and products we use with a supplier?

Non-Cancer terminal illness that can affect young (age 10-13) girls?

Existence of Riemann surface, holomorphic maps

Does Skippy chunky peanut butter contain trans fat?

What is a DAG (Graph Theory)?

Removing whitespace between consecutive numbers

How can I play a serial killer in a party of good PCs?

What happens when I Twin Life Transference?

How does one write from a minority culture? A question on cultural references

Does diversity provide anything that meritocracy does not?

Is a new boolean field better than null reference when a value can be meaningfully absent?

Current across a wire with zero potential difference

I have trouble understanding this fallacy: "If A, then B. Therefore if not-B, then not-A."

What happened to my GE option?

Hilchos Shabbos English Sefer

What is a good reason for every spaceship to carry a weapon on board?



rsync: delete except on one folder


rsync verify a file already exists in dest folder so it will skip the copy on the 1st syncHelp with rsync excludes not workingHow do I make rsync delete files that have been deleted from the source folder?rsync back up of entire root system not working using --exclude?rsync without deleting between 2 foldersWhy is rsync copying directory structure when my find result only shows me files?a question about my rsync scriptrsync --delete option not deleting in destination if deleted in sourcersync doesn't sync changesexcluding hidden files only in a particular directory













0















I have a tree that is like this: /home/me/A/secret/. I'd like to sync (recursively) the folder /home/me/A/ (including the subfolder secret), in the folder /opt of the destination. Moreover, I also would like to delete the files that are in the source but not in the destination, except if the files belong to the secret folder.



Indeed, the secret folder won't be always present on the machine, and I don't want to remove the secret folder on the remote server when it's the case.



What I tried: the option --delete deletes everything, so I tried --delete --exclude secret/, but the problem is that it won't even sync the content of secret/. Then, --filter "protect ..." requires a file with all the files that I want to protect, which is really not practical.



So for now the best option I found is to run two instances of rsync: one with --exclude secret/ --delete to deal with everything except the secret folder, and then I run another rsync to sync directly the subfolder secret to the good position.



Is there a one-command way to do that?



Thanks!









share



























    0















    I have a tree that is like this: /home/me/A/secret/. I'd like to sync (recursively) the folder /home/me/A/ (including the subfolder secret), in the folder /opt of the destination. Moreover, I also would like to delete the files that are in the source but not in the destination, except if the files belong to the secret folder.



    Indeed, the secret folder won't be always present on the machine, and I don't want to remove the secret folder on the remote server when it's the case.



    What I tried: the option --delete deletes everything, so I tried --delete --exclude secret/, but the problem is that it won't even sync the content of secret/. Then, --filter "protect ..." requires a file with all the files that I want to protect, which is really not practical.



    So for now the best option I found is to run two instances of rsync: one with --exclude secret/ --delete to deal with everything except the secret folder, and then I run another rsync to sync directly the subfolder secret to the good position.



    Is there a one-command way to do that?



    Thanks!









    share

























      0












      0








      0








      I have a tree that is like this: /home/me/A/secret/. I'd like to sync (recursively) the folder /home/me/A/ (including the subfolder secret), in the folder /opt of the destination. Moreover, I also would like to delete the files that are in the source but not in the destination, except if the files belong to the secret folder.



      Indeed, the secret folder won't be always present on the machine, and I don't want to remove the secret folder on the remote server when it's the case.



      What I tried: the option --delete deletes everything, so I tried --delete --exclude secret/, but the problem is that it won't even sync the content of secret/. Then, --filter "protect ..." requires a file with all the files that I want to protect, which is really not practical.



      So for now the best option I found is to run two instances of rsync: one with --exclude secret/ --delete to deal with everything except the secret folder, and then I run another rsync to sync directly the subfolder secret to the good position.



      Is there a one-command way to do that?



      Thanks!









      share














      I have a tree that is like this: /home/me/A/secret/. I'd like to sync (recursively) the folder /home/me/A/ (including the subfolder secret), in the folder /opt of the destination. Moreover, I also would like to delete the files that are in the source but not in the destination, except if the files belong to the secret folder.



      Indeed, the secret folder won't be always present on the machine, and I don't want to remove the secret folder on the remote server when it's the case.



      What I tried: the option --delete deletes everything, so I tried --delete --exclude secret/, but the problem is that it won't even sync the content of secret/. Then, --filter "protect ..." requires a file with all the files that I want to protect, which is really not practical.



      So for now the best option I found is to run two instances of rsync: one with --exclude secret/ --delete to deal with everything except the secret folder, and then I run another rsync to sync directly the subfolder secret to the good position.



      Is there a one-command way to do that?



      Thanks!







      rsync





      share












      share










      share



      share










      asked 2 mins ago









      tobiasBoratobiasBora

      943810




      943810






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          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%2faskubuntu.com%2fquestions%2f1121584%2frsync-delete-except-on-one-folder%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Ask Ubuntu!


          • 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%2faskubuntu.com%2fquestions%2f1121584%2frsync-delete-except-on-one-folder%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

          Why do type traits not work with types in namespace scope?What are POD types in C++?Why can templates only be...

          Will tsunami waves travel forever if there was no land?Why do tsunami waves begin with the water flowing away...

          Should I use Docker or LXD?How to cache (more) data on SSD/RAM to avoid spin up?Unable to get Windows File...