tar --exclude=“filename.extension” not working combined with docker commands

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











up vote
0
down vote

favorite












So I first testing a simpler scenario I was able to correctly use the tar --exclude option, in the simple scenario, a folder, "pack" contains two files:



  1. text.txt

  2. mongod.lock

Screenshot of pack folder:



enter image description here



Running the command:



tar --exclude='mongod.lock' -cvf foo.tar -C /home/bogden/repos/devops/scripts/pack .


This correctly ignored a file named "mongod.lock" in the "pack" folder, created a tar named "foo.tar", that contained one file, tar verbose output:



enter image description here



The unpacking of the tar archive proves "mongod.lock" was ignored:



enter image description here



Now in my scenario I am archiving a docker container volume, and trying to exclude this "mongod.lock". The fact that this is a docker container volume does not matter that much except perhaps some kind of file path I need to include in my --exclude= pattern.



docker run --rm --volumes-from example.db.container -v /backup/volumes:/backup centos7 tar --exclude='mongod.lock' -cvf /backup/backup.tar -C /data/db .


the mongod.lock is archived as well, it is not excluded:



enter image description here



I have also tried --exclude= patterns:



  • ./mongod.lock

  • /mongod.lock

  • **.lock

  • /data/db/mongod.lock

I am guessing I have some folder path that I need to include in my ignore pattern but I am not sure







share|improve this question
























    up vote
    0
    down vote

    favorite












    So I first testing a simpler scenario I was able to correctly use the tar --exclude option, in the simple scenario, a folder, "pack" contains two files:



    1. text.txt

    2. mongod.lock

    Screenshot of pack folder:



    enter image description here



    Running the command:



    tar --exclude='mongod.lock' -cvf foo.tar -C /home/bogden/repos/devops/scripts/pack .


    This correctly ignored a file named "mongod.lock" in the "pack" folder, created a tar named "foo.tar", that contained one file, tar verbose output:



    enter image description here



    The unpacking of the tar archive proves "mongod.lock" was ignored:



    enter image description here



    Now in my scenario I am archiving a docker container volume, and trying to exclude this "mongod.lock". The fact that this is a docker container volume does not matter that much except perhaps some kind of file path I need to include in my --exclude= pattern.



    docker run --rm --volumes-from example.db.container -v /backup/volumes:/backup centos7 tar --exclude='mongod.lock' -cvf /backup/backup.tar -C /data/db .


    the mongod.lock is archived as well, it is not excluded:



    enter image description here



    I have also tried --exclude= patterns:



    • ./mongod.lock

    • /mongod.lock

    • **.lock

    • /data/db/mongod.lock

    I am guessing I have some folder path that I need to include in my ignore pattern but I am not sure







    share|improve this question






















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      So I first testing a simpler scenario I was able to correctly use the tar --exclude option, in the simple scenario, a folder, "pack" contains two files:



      1. text.txt

      2. mongod.lock

      Screenshot of pack folder:



      enter image description here



      Running the command:



      tar --exclude='mongod.lock' -cvf foo.tar -C /home/bogden/repos/devops/scripts/pack .


      This correctly ignored a file named "mongod.lock" in the "pack" folder, created a tar named "foo.tar", that contained one file, tar verbose output:



      enter image description here



      The unpacking of the tar archive proves "mongod.lock" was ignored:



      enter image description here



      Now in my scenario I am archiving a docker container volume, and trying to exclude this "mongod.lock". The fact that this is a docker container volume does not matter that much except perhaps some kind of file path I need to include in my --exclude= pattern.



      docker run --rm --volumes-from example.db.container -v /backup/volumes:/backup centos7 tar --exclude='mongod.lock' -cvf /backup/backup.tar -C /data/db .


      the mongod.lock is archived as well, it is not excluded:



      enter image description here



      I have also tried --exclude= patterns:



      • ./mongod.lock

      • /mongod.lock

      • **.lock

      • /data/db/mongod.lock

      I am guessing I have some folder path that I need to include in my ignore pattern but I am not sure







      share|improve this question












      So I first testing a simpler scenario I was able to correctly use the tar --exclude option, in the simple scenario, a folder, "pack" contains two files:



      1. text.txt

      2. mongod.lock

      Screenshot of pack folder:



      enter image description here



      Running the command:



      tar --exclude='mongod.lock' -cvf foo.tar -C /home/bogden/repos/devops/scripts/pack .


      This correctly ignored a file named "mongod.lock" in the "pack" folder, created a tar named "foo.tar", that contained one file, tar verbose output:



      enter image description here



      The unpacking of the tar archive proves "mongod.lock" was ignored:



      enter image description here



      Now in my scenario I am archiving a docker container volume, and trying to exclude this "mongod.lock". The fact that this is a docker container volume does not matter that much except perhaps some kind of file path I need to include in my --exclude= pattern.



      docker run --rm --volumes-from example.db.container -v /backup/volumes:/backup centos7 tar --exclude='mongod.lock' -cvf /backup/backup.tar -C /data/db .


      the mongod.lock is archived as well, it is not excluded:



      enter image description here



      I have also tried --exclude= patterns:



      • ./mongod.lock

      • /mongod.lock

      • **.lock

      • /data/db/mongod.lock

      I am guessing I have some folder path that I need to include in my ignore pattern but I am not sure









      share|improve this question











      share|improve this question




      share|improve this question










      asked Oct 20 '17 at 16:27









      Brian Ogden

      1014




      1014

























          active

          oldest

          votes











          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%2f399384%2ftar-exclude-filename-extension-not-working-combined-with-docker-commands%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f399384%2ftar-exclude-filename-extension-not-working-combined-with-docker-commands%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?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay