AWS upload folder to S3 as tar.gz without compressing locally












5














In AWS CLI, how do I upload a folder as a tar.gz file without creating a tar.gz locally?



For example, I have a folder at /var/test and I want to upload it to /tests/test1.tar.gz



How do I do that without turning it into a tar.gz locally? (I want to save local space, as I don't have much space on my HDD.)










share|improve this question





























    5














    In AWS CLI, how do I upload a folder as a tar.gz file without creating a tar.gz locally?



    For example, I have a folder at /var/test and I want to upload it to /tests/test1.tar.gz



    How do I do that without turning it into a tar.gz locally? (I want to save local space, as I don't have much space on my HDD.)










    share|improve this question



























      5












      5








      5


      1





      In AWS CLI, how do I upload a folder as a tar.gz file without creating a tar.gz locally?



      For example, I have a folder at /var/test and I want to upload it to /tests/test1.tar.gz



      How do I do that without turning it into a tar.gz locally? (I want to save local space, as I don't have much space on my HDD.)










      share|improve this question















      In AWS CLI, how do I upload a folder as a tar.gz file without creating a tar.gz locally?



      For example, I have a folder at /var/test and I want to upload it to /tests/test1.tar.gz



      How do I do that without turning it into a tar.gz locally? (I want to save local space, as I don't have much space on my HDD.)







      tar amazon-web-services amazon-s3






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 7 '17 at 16:03









      Scott

      15.6k113889




      15.6k113889










      asked Sep 7 '17 at 15:00









      Michael SamsungMichael Samsung

      2612




      2612






















          1 Answer
          1






          active

          oldest

          votes


















          9














          What you're really looking for is not saving a local file. You can use pipes to send the data from tar through gzip to s3 without saving anything to disk.



          tar c /var/test | gzip | aws s3 cp - "s3://tests/test1.tar.gz"


          Breaking this down (where stdin and stdout refer to the standard input/output streams via the pipeline):





          • tar c /var/test creates a tar archive out of /var/test and outputs it to stdout...

          • ...which is read by gzip from stdin, and the gzipped file (.tar.gz) is output to stdout...

          • ...which is read by aws s3 cp - "s3://tests/test1.tar.gz" from stdin and sent to S3. The - tells the AWS CLI to copy from stdin.


          This still performs the gzip operation locally, but does not require the creation of a temporary file, since the entire stream is sent straight over the network.






          share|improve this answer























          • Bob, this answer looks like it's correct for SSHing files to other servers, but doesn't seem to address the question of how to upload to S3. It's probably a reasonably simple extension for someone who understands the S3 command line tools to apply this technique.
            – Tim
            Sep 8 '17 at 0:59












          • @Tim ...somehow, I completely missed that. I'll update.
            – Bob
            Sep 8 '17 at 1:04






          • 1




            @Tim Fixed. Probably only looked at the AWS bit and assumed EC2 while half asleep last night.
            – Bob
            Sep 8 '17 at 1:11








          • 1




            A few questions about this solution: - will it work with directories too? - will the entire contents of the files be loaded in memory? Doesn't this give problems with large files? - is there any way to see progress?
            – murze
            Jun 10 '18 at 9:51








          • 1




            @murze (1) of course, that's the whole point of packaging, (2) no, (3) no, (4) no.
            – Ekevoo
            Sep 12 '18 at 17:50











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          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%2fsuperuser.com%2fquestions%2f1248276%2faws-upload-folder-to-s3-as-tar-gz-without-compressing-locally%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          9














          What you're really looking for is not saving a local file. You can use pipes to send the data from tar through gzip to s3 without saving anything to disk.



          tar c /var/test | gzip | aws s3 cp - "s3://tests/test1.tar.gz"


          Breaking this down (where stdin and stdout refer to the standard input/output streams via the pipeline):





          • tar c /var/test creates a tar archive out of /var/test and outputs it to stdout...

          • ...which is read by gzip from stdin, and the gzipped file (.tar.gz) is output to stdout...

          • ...which is read by aws s3 cp - "s3://tests/test1.tar.gz" from stdin and sent to S3. The - tells the AWS CLI to copy from stdin.


          This still performs the gzip operation locally, but does not require the creation of a temporary file, since the entire stream is sent straight over the network.






          share|improve this answer























          • Bob, this answer looks like it's correct for SSHing files to other servers, but doesn't seem to address the question of how to upload to S3. It's probably a reasonably simple extension for someone who understands the S3 command line tools to apply this technique.
            – Tim
            Sep 8 '17 at 0:59












          • @Tim ...somehow, I completely missed that. I'll update.
            – Bob
            Sep 8 '17 at 1:04






          • 1




            @Tim Fixed. Probably only looked at the AWS bit and assumed EC2 while half asleep last night.
            – Bob
            Sep 8 '17 at 1:11








          • 1




            A few questions about this solution: - will it work with directories too? - will the entire contents of the files be loaded in memory? Doesn't this give problems with large files? - is there any way to see progress?
            – murze
            Jun 10 '18 at 9:51








          • 1




            @murze (1) of course, that's the whole point of packaging, (2) no, (3) no, (4) no.
            – Ekevoo
            Sep 12 '18 at 17:50
















          9














          What you're really looking for is not saving a local file. You can use pipes to send the data from tar through gzip to s3 without saving anything to disk.



          tar c /var/test | gzip | aws s3 cp - "s3://tests/test1.tar.gz"


          Breaking this down (where stdin and stdout refer to the standard input/output streams via the pipeline):





          • tar c /var/test creates a tar archive out of /var/test and outputs it to stdout...

          • ...which is read by gzip from stdin, and the gzipped file (.tar.gz) is output to stdout...

          • ...which is read by aws s3 cp - "s3://tests/test1.tar.gz" from stdin and sent to S3. The - tells the AWS CLI to copy from stdin.


          This still performs the gzip operation locally, but does not require the creation of a temporary file, since the entire stream is sent straight over the network.






          share|improve this answer























          • Bob, this answer looks like it's correct for SSHing files to other servers, but doesn't seem to address the question of how to upload to S3. It's probably a reasonably simple extension for someone who understands the S3 command line tools to apply this technique.
            – Tim
            Sep 8 '17 at 0:59












          • @Tim ...somehow, I completely missed that. I'll update.
            – Bob
            Sep 8 '17 at 1:04






          • 1




            @Tim Fixed. Probably only looked at the AWS bit and assumed EC2 while half asleep last night.
            – Bob
            Sep 8 '17 at 1:11








          • 1




            A few questions about this solution: - will it work with directories too? - will the entire contents of the files be loaded in memory? Doesn't this give problems with large files? - is there any way to see progress?
            – murze
            Jun 10 '18 at 9:51








          • 1




            @murze (1) of course, that's the whole point of packaging, (2) no, (3) no, (4) no.
            – Ekevoo
            Sep 12 '18 at 17:50














          9












          9








          9






          What you're really looking for is not saving a local file. You can use pipes to send the data from tar through gzip to s3 without saving anything to disk.



          tar c /var/test | gzip | aws s3 cp - "s3://tests/test1.tar.gz"


          Breaking this down (where stdin and stdout refer to the standard input/output streams via the pipeline):





          • tar c /var/test creates a tar archive out of /var/test and outputs it to stdout...

          • ...which is read by gzip from stdin, and the gzipped file (.tar.gz) is output to stdout...

          • ...which is read by aws s3 cp - "s3://tests/test1.tar.gz" from stdin and sent to S3. The - tells the AWS CLI to copy from stdin.


          This still performs the gzip operation locally, but does not require the creation of a temporary file, since the entire stream is sent straight over the network.






          share|improve this answer














          What you're really looking for is not saving a local file. You can use pipes to send the data from tar through gzip to s3 without saving anything to disk.



          tar c /var/test | gzip | aws s3 cp - "s3://tests/test1.tar.gz"


          Breaking this down (where stdin and stdout refer to the standard input/output streams via the pipeline):





          • tar c /var/test creates a tar archive out of /var/test and outputs it to stdout...

          • ...which is read by gzip from stdin, and the gzipped file (.tar.gz) is output to stdout...

          • ...which is read by aws s3 cp - "s3://tests/test1.tar.gz" from stdin and sent to S3. The - tells the AWS CLI to copy from stdin.


          This still performs the gzip operation locally, but does not require the creation of a temporary file, since the entire stream is sent straight over the network.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Sep 8 '17 at 1:34

























          answered Sep 7 '17 at 15:18









          BobBob

          45.4k20137172




          45.4k20137172












          • Bob, this answer looks like it's correct for SSHing files to other servers, but doesn't seem to address the question of how to upload to S3. It's probably a reasonably simple extension for someone who understands the S3 command line tools to apply this technique.
            – Tim
            Sep 8 '17 at 0:59












          • @Tim ...somehow, I completely missed that. I'll update.
            – Bob
            Sep 8 '17 at 1:04






          • 1




            @Tim Fixed. Probably only looked at the AWS bit and assumed EC2 while half asleep last night.
            – Bob
            Sep 8 '17 at 1:11








          • 1




            A few questions about this solution: - will it work with directories too? - will the entire contents of the files be loaded in memory? Doesn't this give problems with large files? - is there any way to see progress?
            – murze
            Jun 10 '18 at 9:51








          • 1




            @murze (1) of course, that's the whole point of packaging, (2) no, (3) no, (4) no.
            – Ekevoo
            Sep 12 '18 at 17:50


















          • Bob, this answer looks like it's correct for SSHing files to other servers, but doesn't seem to address the question of how to upload to S3. It's probably a reasonably simple extension for someone who understands the S3 command line tools to apply this technique.
            – Tim
            Sep 8 '17 at 0:59












          • @Tim ...somehow, I completely missed that. I'll update.
            – Bob
            Sep 8 '17 at 1:04






          • 1




            @Tim Fixed. Probably only looked at the AWS bit and assumed EC2 while half asleep last night.
            – Bob
            Sep 8 '17 at 1:11








          • 1




            A few questions about this solution: - will it work with directories too? - will the entire contents of the files be loaded in memory? Doesn't this give problems with large files? - is there any way to see progress?
            – murze
            Jun 10 '18 at 9:51








          • 1




            @murze (1) of course, that's the whole point of packaging, (2) no, (3) no, (4) no.
            – Ekevoo
            Sep 12 '18 at 17:50
















          Bob, this answer looks like it's correct for SSHing files to other servers, but doesn't seem to address the question of how to upload to S3. It's probably a reasonably simple extension for someone who understands the S3 command line tools to apply this technique.
          – Tim
          Sep 8 '17 at 0:59






          Bob, this answer looks like it's correct for SSHing files to other servers, but doesn't seem to address the question of how to upload to S3. It's probably a reasonably simple extension for someone who understands the S3 command line tools to apply this technique.
          – Tim
          Sep 8 '17 at 0:59














          @Tim ...somehow, I completely missed that. I'll update.
          – Bob
          Sep 8 '17 at 1:04




          @Tim ...somehow, I completely missed that. I'll update.
          – Bob
          Sep 8 '17 at 1:04




          1




          1




          @Tim Fixed. Probably only looked at the AWS bit and assumed EC2 while half asleep last night.
          – Bob
          Sep 8 '17 at 1:11






          @Tim Fixed. Probably only looked at the AWS bit and assumed EC2 while half asleep last night.
          – Bob
          Sep 8 '17 at 1:11






          1




          1




          A few questions about this solution: - will it work with directories too? - will the entire contents of the files be loaded in memory? Doesn't this give problems with large files? - is there any way to see progress?
          – murze
          Jun 10 '18 at 9:51






          A few questions about this solution: - will it work with directories too? - will the entire contents of the files be loaded in memory? Doesn't this give problems with large files? - is there any way to see progress?
          – murze
          Jun 10 '18 at 9:51






          1




          1




          @murze (1) of course, that's the whole point of packaging, (2) no, (3) no, (4) no.
          – Ekevoo
          Sep 12 '18 at 17:50




          @murze (1) of course, that's the whole point of packaging, (2) no, (3) no, (4) no.
          – Ekevoo
          Sep 12 '18 at 17:50


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • 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%2fsuperuser.com%2fquestions%2f1248276%2faws-upload-folder-to-s3-as-tar-gz-without-compressing-locally%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