gzip compress a local folder and extract it to remote serverExtract timestamp from a gzip fileUnrar local files to remote serverUse gzip to compress the files in a directory except for already existing .gz filesWhat's the difference between gzip and compress?use tar to extract and immediately compress files from tarballCopy contents of remote server folder to current server?tail file from remote server and nslookup on localHow to gzip and copy files keeping its directory structure?local folder connected with SSH from servercompress file using /bin/gzip with particular patterns

Does this house rule, for determining hit point maximum, make characters weaker than RAW?

What does "another" mean in this case?

Should I cheat if the majority does it?

gzip compress a local folder and extract it to remote server

Solving Equations with HeavisideTheta Functions

"Best practices" for formulating MIPs

List of Implementations for common OR problems

What is a "tittering order"?

Show that there are infinitely more problems than we will ever be able to compute

Turing Machines: What is the difference between recognizing, deciding, total, accepting, rejecting?

SQL Server error 242 with ANSI datetime

My players like to search everything. What do they find?

Why is the saxophone not common in classical repertoire?

Which high-degree derivatives play an essential role?

Do human thoughts interact with matter?

How can solar sailed ships be protected from space debris?

How frequently do Russian people still refer to others by their patronymic (отчество)?

Contributing to a candidate as a Foreign National US Resident?

Is it possible that Curiosity measured its own methane or failed doing the spectrometry?

Do the 26 richest billionaires own as much wealth as the poorest 3.8 billion people?

How is /a/ pronounced before n/m in French?

Performance of loop vs expansion

Can you use a reaction to affect initiative rolls?

What is the difference between a historical drama and a period drama?



gzip compress a local folder and extract it to remote server


Extract timestamp from a gzip fileUnrar local files to remote serverUse gzip to compress the files in a directory except for already existing .gz filesWhat's the difference between gzip and compress?use tar to extract and immediately compress files from tarballCopy contents of remote server folder to current server?tail file from remote server and nslookup on localHow to gzip and copy files keeping its directory structure?local folder connected with SSH from servercompress file using /bin/gzip with particular patterns






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I am new to these commands. I am trying to gzip a local folder and unzip the same on the remote server. The thing is gzipping and unzip must happen on the fly. I tried many and one of the closest I believe is this:



tar cf dist.tar ~/Documents/projects/myproject/dist/ | ssh root@13.21.13.12:~/public_html/ "tar zx ~/Documents/projects/myproject/dist.tar"


As you can see above, I am trying to send out the dist folder to the remote server.. but before that I am trying to compress the folder on the fly (looks like that is not happening in above command).



  • local folder: ~/Documents/projects/myproject/dist/

  • remote folder: ~/public_html (directly deploying to live)

Ofcourse, the gzip created file must not be there.. it should happen on the fly (I am not sure how exactly to say this.. hope I am making sense).



My intention is to run the above like through a file like sh file.command. i.e I am trying to deploy my compiled project which is in dist folder, to live when the sh command is executed. I don't want to do this manually everytime I make the change in my project.










share|improve this question






























    2















    I am new to these commands. I am trying to gzip a local folder and unzip the same on the remote server. The thing is gzipping and unzip must happen on the fly. I tried many and one of the closest I believe is this:



    tar cf dist.tar ~/Documents/projects/myproject/dist/ | ssh root@13.21.13.12:~/public_html/ "tar zx ~/Documents/projects/myproject/dist.tar"


    As you can see above, I am trying to send out the dist folder to the remote server.. but before that I am trying to compress the folder on the fly (looks like that is not happening in above command).



    • local folder: ~/Documents/projects/myproject/dist/

    • remote folder: ~/public_html (directly deploying to live)

    Ofcourse, the gzip created file must not be there.. it should happen on the fly (I am not sure how exactly to say this.. hope I am making sense).



    My intention is to run the above like through a file like sh file.command. i.e I am trying to deploy my compiled project which is in dist folder, to live when the sh command is executed. I don't want to do this manually everytime I make the change in my project.










    share|improve this question


























      2












      2








      2








      I am new to these commands. I am trying to gzip a local folder and unzip the same on the remote server. The thing is gzipping and unzip must happen on the fly. I tried many and one of the closest I believe is this:



      tar cf dist.tar ~/Documents/projects/myproject/dist/ | ssh root@13.21.13.12:~/public_html/ "tar zx ~/Documents/projects/myproject/dist.tar"


      As you can see above, I am trying to send out the dist folder to the remote server.. but before that I am trying to compress the folder on the fly (looks like that is not happening in above command).



      • local folder: ~/Documents/projects/myproject/dist/

      • remote folder: ~/public_html (directly deploying to live)

      Ofcourse, the gzip created file must not be there.. it should happen on the fly (I am not sure how exactly to say this.. hope I am making sense).



      My intention is to run the above like through a file like sh file.command. i.e I am trying to deploy my compiled project which is in dist folder, to live when the sh command is executed. I don't want to do this manually everytime I make the change in my project.










      share|improve this question
















      I am new to these commands. I am trying to gzip a local folder and unzip the same on the remote server. The thing is gzipping and unzip must happen on the fly. I tried many and one of the closest I believe is this:



      tar cf dist.tar ~/Documents/projects/myproject/dist/ | ssh root@13.21.13.12:~/public_html/ "tar zx ~/Documents/projects/myproject/dist.tar"


      As you can see above, I am trying to send out the dist folder to the remote server.. but before that I am trying to compress the folder on the fly (looks like that is not happening in above command).



      • local folder: ~/Documents/projects/myproject/dist/

      • remote folder: ~/public_html (directly deploying to live)

      Ofcourse, the gzip created file must not be there.. it should happen on the fly (I am not sure how exactly to say this.. hope I am making sense).



      My intention is to run the above like through a file like sh file.command. i.e I am trying to deploy my compiled project which is in dist folder, to live when the sh command is executed. I don't want to do this manually everytime I make the change in my project.







      ssh terminal osx file-copy gzip






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 8 hours ago









      roaima

      47.8k7 gold badges62 silver badges131 bronze badges




      47.8k7 gold badges62 silver badges131 bronze badges










      asked 9 hours ago









      Mr_GreenMr_Green

      1201 gold badge1 silver badge6 bronze badges




      1201 gold badge1 silver badge6 bronze badges




















          3 Answers
          3






          active

          oldest

          votes


















          3














          If you have rsync then use that instead, as it makes use of existing files to allow it to transfer only differences (that is, parts of files that are different):



          rsync -az ~/Documents/projects/myproject/dist/ root@13.21.13.12:public_html/


          Add the --delete flag to to completely overwrite the target directory tree each time. If you want to see what's going on, add -v.



          If you don't have rsync, then this less efficient solution using tar will suffice:



          ( cd ~/Documents/projects/myproject/dist && tar czf - . ) |
          ssh root@13.21.13.12 'cd public_html && tar xzf -'


          Notice that the writing and reading of the compressed tarball is via stdout and stdin (the - filename), and the -C is used to set the correct directory before processing. Add the v flag (on the receiving side) to see what's going on, i.e. tar xzvf ....






          share|improve this answer

























          • Thanks.. somehow tar didn't work me at all.. rsync worked as smooth as butter :D.. Did brew install rsync to install it before.

            – Mr_Green
            9 hours ago











          • Isn't brew a Mac thing?

            – roaima
            8 hours ago












          • yeah, I am on mac. btw, when I tried the same again it is ending up fast saying sending incremental file list.. is this fine?

            – Mr_Green
            8 hours ago











          • yeah seems fine.. it is just taking the changed files and deploying instead of all files again. seems it is tracking the changes somehow.

            – Mr_Green
            8 hours ago






          • 1





            I've simplified the tar command so that it should now work on a Mac. But rsync is still better.

            – roaima
            8 hours ago



















          1














          You are telling tar to write the tarball into the file dist.tar. With this command you are not sending the tarball to the remote machine.



          You must make tar write its output to stdout using -f -. The hyphen means stdout. If you add a -z option, then tar will compress the tarball before writing it to stdout, which is a good idea in 99% of all use-cases where one sends a tarball to a remote machine.



          On the remote side you extract with tar -x. In your example you have the -z option only on the remote side. This does not make sense. You must select the same compression method on both sides, i.e. use -z on both sides or don't use it on both sides.



          This might work for you



          tar -czf - ~/Documents/projects/myproject/dist/ | ssh root@13.21.13.12 "tar -C ~/public_html/ -xzf -"


          (Disclaimer: I didn't try it out. It may contain errors.)



          Since the remote tar is supposed to read the tarball from stdin, you don't provide a filename on this side too.






          share|improve this answer


















          • 1





            Thanks for the answer.. I am not sure whether this error.. I am seeing Removing leading '/' from member names. it just runs without any messages and when I check the remote.. I am seeing no change.

            – Mr_Green
            9 hours ago


















          1














          Instead of creating a file on disk, you need to send the output of tar to STDOUT, so it can then be sent over the wire using ssh:



          $ tar -zcf - /path/to/files | ssh user@host "tar -zx - -C /path/to/destination"


          Note the "-" characters where you are using file names. These tell tar on the sending side to write to STDOUT, and on the receiving side to read from STDIN. The archived data never gets written to the local disk.



          You can't specify a path when logging in with ssh (at least, I've never figured out how to), so you need to tell tar on the receiving side where to write its output - that's what the -C /path/to/destination is for.



          As currently written, the command would lead to files being written on the remote side nested in the local directories - you'd end up with



          /path/to/files/index.html --> /path/to/destination/path/to/files/index.html


          If, instead, you want /path/to/destination/index.html, say this:



          $ tar -zcf - -C /path/to/files . | ssh user@host "tar -zx - -C /path/to/destination"





          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%2f527870%2fgzip-compress-a-local-folder-and-extract-it-to-remote-server%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3














            If you have rsync then use that instead, as it makes use of existing files to allow it to transfer only differences (that is, parts of files that are different):



            rsync -az ~/Documents/projects/myproject/dist/ root@13.21.13.12:public_html/


            Add the --delete flag to to completely overwrite the target directory tree each time. If you want to see what's going on, add -v.



            If you don't have rsync, then this less efficient solution using tar will suffice:



            ( cd ~/Documents/projects/myproject/dist && tar czf - . ) |
            ssh root@13.21.13.12 'cd public_html && tar xzf -'


            Notice that the writing and reading of the compressed tarball is via stdout and stdin (the - filename), and the -C is used to set the correct directory before processing. Add the v flag (on the receiving side) to see what's going on, i.e. tar xzvf ....






            share|improve this answer

























            • Thanks.. somehow tar didn't work me at all.. rsync worked as smooth as butter :D.. Did brew install rsync to install it before.

              – Mr_Green
              9 hours ago











            • Isn't brew a Mac thing?

              – roaima
              8 hours ago












            • yeah, I am on mac. btw, when I tried the same again it is ending up fast saying sending incremental file list.. is this fine?

              – Mr_Green
              8 hours ago











            • yeah seems fine.. it is just taking the changed files and deploying instead of all files again. seems it is tracking the changes somehow.

              – Mr_Green
              8 hours ago






            • 1





              I've simplified the tar command so that it should now work on a Mac. But rsync is still better.

              – roaima
              8 hours ago
















            3














            If you have rsync then use that instead, as it makes use of existing files to allow it to transfer only differences (that is, parts of files that are different):



            rsync -az ~/Documents/projects/myproject/dist/ root@13.21.13.12:public_html/


            Add the --delete flag to to completely overwrite the target directory tree each time. If you want to see what's going on, add -v.



            If you don't have rsync, then this less efficient solution using tar will suffice:



            ( cd ~/Documents/projects/myproject/dist && tar czf - . ) |
            ssh root@13.21.13.12 'cd public_html && tar xzf -'


            Notice that the writing and reading of the compressed tarball is via stdout and stdin (the - filename), and the -C is used to set the correct directory before processing. Add the v flag (on the receiving side) to see what's going on, i.e. tar xzvf ....






            share|improve this answer

























            • Thanks.. somehow tar didn't work me at all.. rsync worked as smooth as butter :D.. Did brew install rsync to install it before.

              – Mr_Green
              9 hours ago











            • Isn't brew a Mac thing?

              – roaima
              8 hours ago












            • yeah, I am on mac. btw, when I tried the same again it is ending up fast saying sending incremental file list.. is this fine?

              – Mr_Green
              8 hours ago











            • yeah seems fine.. it is just taking the changed files and deploying instead of all files again. seems it is tracking the changes somehow.

              – Mr_Green
              8 hours ago






            • 1





              I've simplified the tar command so that it should now work on a Mac. But rsync is still better.

              – roaima
              8 hours ago














            3












            3








            3







            If you have rsync then use that instead, as it makes use of existing files to allow it to transfer only differences (that is, parts of files that are different):



            rsync -az ~/Documents/projects/myproject/dist/ root@13.21.13.12:public_html/


            Add the --delete flag to to completely overwrite the target directory tree each time. If you want to see what's going on, add -v.



            If you don't have rsync, then this less efficient solution using tar will suffice:



            ( cd ~/Documents/projects/myproject/dist && tar czf - . ) |
            ssh root@13.21.13.12 'cd public_html && tar xzf -'


            Notice that the writing and reading of the compressed tarball is via stdout and stdin (the - filename), and the -C is used to set the correct directory before processing. Add the v flag (on the receiving side) to see what's going on, i.e. tar xzvf ....






            share|improve this answer















            If you have rsync then use that instead, as it makes use of existing files to allow it to transfer only differences (that is, parts of files that are different):



            rsync -az ~/Documents/projects/myproject/dist/ root@13.21.13.12:public_html/


            Add the --delete flag to to completely overwrite the target directory tree each time. If you want to see what's going on, add -v.



            If you don't have rsync, then this less efficient solution using tar will suffice:



            ( cd ~/Documents/projects/myproject/dist && tar czf - . ) |
            ssh root@13.21.13.12 'cd public_html && tar xzf -'


            Notice that the writing and reading of the compressed tarball is via stdout and stdin (the - filename), and the -C is used to set the correct directory before processing. Add the v flag (on the receiving side) to see what's going on, i.e. tar xzvf ....







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 8 hours ago

























            answered 9 hours ago









            roaimaroaima

            47.8k7 gold badges62 silver badges131 bronze badges




            47.8k7 gold badges62 silver badges131 bronze badges












            • Thanks.. somehow tar didn't work me at all.. rsync worked as smooth as butter :D.. Did brew install rsync to install it before.

              – Mr_Green
              9 hours ago











            • Isn't brew a Mac thing?

              – roaima
              8 hours ago












            • yeah, I am on mac. btw, when I tried the same again it is ending up fast saying sending incremental file list.. is this fine?

              – Mr_Green
              8 hours ago











            • yeah seems fine.. it is just taking the changed files and deploying instead of all files again. seems it is tracking the changes somehow.

              – Mr_Green
              8 hours ago






            • 1





              I've simplified the tar command so that it should now work on a Mac. But rsync is still better.

              – roaima
              8 hours ago


















            • Thanks.. somehow tar didn't work me at all.. rsync worked as smooth as butter :D.. Did brew install rsync to install it before.

              – Mr_Green
              9 hours ago











            • Isn't brew a Mac thing?

              – roaima
              8 hours ago












            • yeah, I am on mac. btw, when I tried the same again it is ending up fast saying sending incremental file list.. is this fine?

              – Mr_Green
              8 hours ago











            • yeah seems fine.. it is just taking the changed files and deploying instead of all files again. seems it is tracking the changes somehow.

              – Mr_Green
              8 hours ago






            • 1





              I've simplified the tar command so that it should now work on a Mac. But rsync is still better.

              – roaima
              8 hours ago

















            Thanks.. somehow tar didn't work me at all.. rsync worked as smooth as butter :D.. Did brew install rsync to install it before.

            – Mr_Green
            9 hours ago





            Thanks.. somehow tar didn't work me at all.. rsync worked as smooth as butter :D.. Did brew install rsync to install it before.

            – Mr_Green
            9 hours ago













            Isn't brew a Mac thing?

            – roaima
            8 hours ago






            Isn't brew a Mac thing?

            – roaima
            8 hours ago














            yeah, I am on mac. btw, when I tried the same again it is ending up fast saying sending incremental file list.. is this fine?

            – Mr_Green
            8 hours ago





            yeah, I am on mac. btw, when I tried the same again it is ending up fast saying sending incremental file list.. is this fine?

            – Mr_Green
            8 hours ago













            yeah seems fine.. it is just taking the changed files and deploying instead of all files again. seems it is tracking the changes somehow.

            – Mr_Green
            8 hours ago





            yeah seems fine.. it is just taking the changed files and deploying instead of all files again. seems it is tracking the changes somehow.

            – Mr_Green
            8 hours ago




            1




            1





            I've simplified the tar command so that it should now work on a Mac. But rsync is still better.

            – roaima
            8 hours ago






            I've simplified the tar command so that it should now work on a Mac. But rsync is still better.

            – roaima
            8 hours ago














            1














            You are telling tar to write the tarball into the file dist.tar. With this command you are not sending the tarball to the remote machine.



            You must make tar write its output to stdout using -f -. The hyphen means stdout. If you add a -z option, then tar will compress the tarball before writing it to stdout, which is a good idea in 99% of all use-cases where one sends a tarball to a remote machine.



            On the remote side you extract with tar -x. In your example you have the -z option only on the remote side. This does not make sense. You must select the same compression method on both sides, i.e. use -z on both sides or don't use it on both sides.



            This might work for you



            tar -czf - ~/Documents/projects/myproject/dist/ | ssh root@13.21.13.12 "tar -C ~/public_html/ -xzf -"


            (Disclaimer: I didn't try it out. It may contain errors.)



            Since the remote tar is supposed to read the tarball from stdin, you don't provide a filename on this side too.






            share|improve this answer


















            • 1





              Thanks for the answer.. I am not sure whether this error.. I am seeing Removing leading '/' from member names. it just runs without any messages and when I check the remote.. I am seeing no change.

              – Mr_Green
              9 hours ago















            1














            You are telling tar to write the tarball into the file dist.tar. With this command you are not sending the tarball to the remote machine.



            You must make tar write its output to stdout using -f -. The hyphen means stdout. If you add a -z option, then tar will compress the tarball before writing it to stdout, which is a good idea in 99% of all use-cases where one sends a tarball to a remote machine.



            On the remote side you extract with tar -x. In your example you have the -z option only on the remote side. This does not make sense. You must select the same compression method on both sides, i.e. use -z on both sides or don't use it on both sides.



            This might work for you



            tar -czf - ~/Documents/projects/myproject/dist/ | ssh root@13.21.13.12 "tar -C ~/public_html/ -xzf -"


            (Disclaimer: I didn't try it out. It may contain errors.)



            Since the remote tar is supposed to read the tarball from stdin, you don't provide a filename on this side too.






            share|improve this answer


















            • 1





              Thanks for the answer.. I am not sure whether this error.. I am seeing Removing leading '/' from member names. it just runs without any messages and when I check the remote.. I am seeing no change.

              – Mr_Green
              9 hours ago













            1












            1








            1







            You are telling tar to write the tarball into the file dist.tar. With this command you are not sending the tarball to the remote machine.



            You must make tar write its output to stdout using -f -. The hyphen means stdout. If you add a -z option, then tar will compress the tarball before writing it to stdout, which is a good idea in 99% of all use-cases where one sends a tarball to a remote machine.



            On the remote side you extract with tar -x. In your example you have the -z option only on the remote side. This does not make sense. You must select the same compression method on both sides, i.e. use -z on both sides or don't use it on both sides.



            This might work for you



            tar -czf - ~/Documents/projects/myproject/dist/ | ssh root@13.21.13.12 "tar -C ~/public_html/ -xzf -"


            (Disclaimer: I didn't try it out. It may contain errors.)



            Since the remote tar is supposed to read the tarball from stdin, you don't provide a filename on this side too.






            share|improve this answer













            You are telling tar to write the tarball into the file dist.tar. With this command you are not sending the tarball to the remote machine.



            You must make tar write its output to stdout using -f -. The hyphen means stdout. If you add a -z option, then tar will compress the tarball before writing it to stdout, which is a good idea in 99% of all use-cases where one sends a tarball to a remote machine.



            On the remote side you extract with tar -x. In your example you have the -z option only on the remote side. This does not make sense. You must select the same compression method on both sides, i.e. use -z on both sides or don't use it on both sides.



            This might work for you



            tar -czf - ~/Documents/projects/myproject/dist/ | ssh root@13.21.13.12 "tar -C ~/public_html/ -xzf -"


            (Disclaimer: I didn't try it out. It may contain errors.)



            Since the remote tar is supposed to read the tarball from stdin, you don't provide a filename on this side too.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 9 hours ago









            BananguinBananguin

            5,55914 silver badges40 bronze badges




            5,55914 silver badges40 bronze badges







            • 1





              Thanks for the answer.. I am not sure whether this error.. I am seeing Removing leading '/' from member names. it just runs without any messages and when I check the remote.. I am seeing no change.

              – Mr_Green
              9 hours ago












            • 1





              Thanks for the answer.. I am not sure whether this error.. I am seeing Removing leading '/' from member names. it just runs without any messages and when I check the remote.. I am seeing no change.

              – Mr_Green
              9 hours ago







            1




            1





            Thanks for the answer.. I am not sure whether this error.. I am seeing Removing leading '/' from member names. it just runs without any messages and when I check the remote.. I am seeing no change.

            – Mr_Green
            9 hours ago





            Thanks for the answer.. I am not sure whether this error.. I am seeing Removing leading '/' from member names. it just runs without any messages and when I check the remote.. I am seeing no change.

            – Mr_Green
            9 hours ago











            1














            Instead of creating a file on disk, you need to send the output of tar to STDOUT, so it can then be sent over the wire using ssh:



            $ tar -zcf - /path/to/files | ssh user@host "tar -zx - -C /path/to/destination"


            Note the "-" characters where you are using file names. These tell tar on the sending side to write to STDOUT, and on the receiving side to read from STDIN. The archived data never gets written to the local disk.



            You can't specify a path when logging in with ssh (at least, I've never figured out how to), so you need to tell tar on the receiving side where to write its output - that's what the -C /path/to/destination is for.



            As currently written, the command would lead to files being written on the remote side nested in the local directories - you'd end up with



            /path/to/files/index.html --> /path/to/destination/path/to/files/index.html


            If, instead, you want /path/to/destination/index.html, say this:



            $ tar -zcf - -C /path/to/files . | ssh user@host "tar -zx - -C /path/to/destination"





            share|improve this answer



























              1














              Instead of creating a file on disk, you need to send the output of tar to STDOUT, so it can then be sent over the wire using ssh:



              $ tar -zcf - /path/to/files | ssh user@host "tar -zx - -C /path/to/destination"


              Note the "-" characters where you are using file names. These tell tar on the sending side to write to STDOUT, and on the receiving side to read from STDIN. The archived data never gets written to the local disk.



              You can't specify a path when logging in with ssh (at least, I've never figured out how to), so you need to tell tar on the receiving side where to write its output - that's what the -C /path/to/destination is for.



              As currently written, the command would lead to files being written on the remote side nested in the local directories - you'd end up with



              /path/to/files/index.html --> /path/to/destination/path/to/files/index.html


              If, instead, you want /path/to/destination/index.html, say this:



              $ tar -zcf - -C /path/to/files . | ssh user@host "tar -zx - -C /path/to/destination"





              share|improve this answer

























                1












                1








                1







                Instead of creating a file on disk, you need to send the output of tar to STDOUT, so it can then be sent over the wire using ssh:



                $ tar -zcf - /path/to/files | ssh user@host "tar -zx - -C /path/to/destination"


                Note the "-" characters where you are using file names. These tell tar on the sending side to write to STDOUT, and on the receiving side to read from STDIN. The archived data never gets written to the local disk.



                You can't specify a path when logging in with ssh (at least, I've never figured out how to), so you need to tell tar on the receiving side where to write its output - that's what the -C /path/to/destination is for.



                As currently written, the command would lead to files being written on the remote side nested in the local directories - you'd end up with



                /path/to/files/index.html --> /path/to/destination/path/to/files/index.html


                If, instead, you want /path/to/destination/index.html, say this:



                $ tar -zcf - -C /path/to/files . | ssh user@host "tar -zx - -C /path/to/destination"





                share|improve this answer













                Instead of creating a file on disk, you need to send the output of tar to STDOUT, so it can then be sent over the wire using ssh:



                $ tar -zcf - /path/to/files | ssh user@host "tar -zx - -C /path/to/destination"


                Note the "-" characters where you are using file names. These tell tar on the sending side to write to STDOUT, and on the receiving side to read from STDIN. The archived data never gets written to the local disk.



                You can't specify a path when logging in with ssh (at least, I've never figured out how to), so you need to tell tar on the receiving side where to write its output - that's what the -C /path/to/destination is for.



                As currently written, the command would lead to files being written on the remote side nested in the local directories - you'd end up with



                /path/to/files/index.html --> /path/to/destination/path/to/files/index.html


                If, instead, you want /path/to/destination/index.html, say this:



                $ tar -zcf - -C /path/to/files . | ssh user@host "tar -zx - -C /path/to/destination"






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 9 hours ago









                D_ByeD_Bye

                11k1 gold badge33 silver badges27 bronze badges




                11k1 gold badge33 silver badges27 bronze badges



























                    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%2f527870%2fgzip-compress-a-local-folder-and-extract-it-to-remote-server%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

                    Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                    Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                    François Viète Contents Biography Work and thought Bibliography See also Notes Further reading External links Navigation menup. 21Google Bookspp. 75–77Google BooksDe thou (from University of Saint Andrews)ArchivedGoogle BooksGoogle BooksGoogle BooksGoogle booksGoogle Bookscc-parthenay.frL'histoire universelle (fr)Universal History (en)ArchivedAdsabs.harvard.eduPagesperso-orange.frArchive.orgChikara Sasaki. Descartes' mathematical thought p.259Google BooksGoogle BooksGoogle Bookspp. 152 and onwardGoogle BooksGoogle BooksScribd.comGoogle Books1257-7979Google BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGallica.bnf.frGoogle BooksGoogle Books"François Viète"Francois Viète: Father of Modern Algebraic NotationThe Lawyer and the GamblerAbout TarporleySite de Jean-Paul GuichardL'algèbre nouvelle"About the Harmonicon"cb120511976(data)1188044800000 0001 0913 5903n82164680ola2013766880073431702w6vt1sb70287374827140948071409480