Recursive scp without following links or creating a giant tar file?












3














So I did a recursive scp on my remote fileserver (in another state) and it created an infinite loop of links on my remote web directory...



http://www.linuxquestions.org/questions/linux-general-1/recursive-scp-w-o-following-links-658857/ says that I can can try creating a giant tar file. There is a problem with this though - I'm running the recursive scp on a Linux machine in my office, and I'm copying the files all to my external hard drive, which is in FAT32 format (because I need something that's readable by both UNIX and Windows). FAT32 doesn't support large filesizes. So I would have to try something different.



There's also a rsync option but the Linux machine in my office is very primitive (it's igel) so it doesn't have rsync...










share|improve this question





























    3














    So I did a recursive scp on my remote fileserver (in another state) and it created an infinite loop of links on my remote web directory...



    http://www.linuxquestions.org/questions/linux-general-1/recursive-scp-w-o-following-links-658857/ says that I can can try creating a giant tar file. There is a problem with this though - I'm running the recursive scp on a Linux machine in my office, and I'm copying the files all to my external hard drive, which is in FAT32 format (because I need something that's readable by both UNIX and Windows). FAT32 doesn't support large filesizes. So I would have to try something different.



    There's also a rsync option but the Linux machine in my office is very primitive (it's igel) so it doesn't have rsync...










    share|improve this question



























      3












      3








      3







      So I did a recursive scp on my remote fileserver (in another state) and it created an infinite loop of links on my remote web directory...



      http://www.linuxquestions.org/questions/linux-general-1/recursive-scp-w-o-following-links-658857/ says that I can can try creating a giant tar file. There is a problem with this though - I'm running the recursive scp on a Linux machine in my office, and I'm copying the files all to my external hard drive, which is in FAT32 format (because I need something that's readable by both UNIX and Windows). FAT32 doesn't support large filesizes. So I would have to try something different.



      There's also a rsync option but the Linux machine in my office is very primitive (it's igel) so it doesn't have rsync...










      share|improve this question















      So I did a recursive scp on my remote fileserver (in another state) and it created an infinite loop of links on my remote web directory...



      http://www.linuxquestions.org/questions/linux-general-1/recursive-scp-w-o-following-links-658857/ says that I can can try creating a giant tar file. There is a problem with this though - I'm running the recursive scp on a Linux machine in my office, and I'm copying the files all to my external hard drive, which is in FAT32 format (because I need something that's readable by both UNIX and Windows). FAT32 doesn't support large filesizes. So I would have to try something different.



      There's also a rsync option but the Linux machine in my office is very primitive (it's igel) so it doesn't have rsync...







      symlink scp






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 9 '12 at 23:29









      Gilles

      528k12810581583




      528k12810581583










      asked Dec 9 '12 at 22:06









      InquilineKea

      1,87992841




      1,87992841






















          3 Answers
          3






          active

          oldest

          votes


















          4














          I would not recommend using scp for transferring large file trees directly,
          because it does not handle neither hard nor soft links properly, also the stream is not compressed.



          I'd recommend cpio with (de)compression on the fly:



          ssh user@host "cd /path/to/files && find . | cpio -ov | bzip2 -c" | bunzip2 -c | cpio -ivd


          Also, find can handle additional conditions, like "files must be less than 4G"



          find . -size -4G | ...


          To make cpio more space-friendly (to handle spaces in file names properly) use



          find . -print0 | cpio -0 -ivd | ...





          share|improve this answer





























            2














            You don't need to create the tar file before sending it. You can make it on the fly:



            cd /source/dir
            tar -cf - . | ssh 'cd /destination/directory && tar -xf -'


            This does require that the remote server accept ssh shell connections, not just scp connections. In theory, it is possible to send arbitrary file trees to the remote side that don't correspond to anything like the local file structure, but I don't know of any existing tool to do this.



            If symbolic links are a problem, you can make a copy of a directory tree that doesn't include symbolic links and that uses up negligible space, assuming the source tree is on a filesystem that supports hard links (so any native unix filesystem, or NTFS, but not FAT). I'm assuming GNU utilities here:



            cd /source/dir
            mkdir ../regular-files-only
            cp -al . ../regular-files-only
            find ../regular-file-only ! -type f ! -type d -delete


            You could also use sftp. sftp -r does not follow symbolic links, unlike scp -r.






            share|improve this answer





























              0














              Another option is to use sftp -r as sftp manual https://www.computerhope.com/unix/sftp.htm says:




              Recursively copy entire directories when uploading and downloading. Note that sftp does not follow symbolic links encountered in the tree traversal.




              So



              sftp -r source@surce_server.com:/source/dir .


              does exactly what you want to do.






              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%2f58037%2frecursive-scp-without-following-links-or-creating-a-giant-tar-file%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









                4














                I would not recommend using scp for transferring large file trees directly,
                because it does not handle neither hard nor soft links properly, also the stream is not compressed.



                I'd recommend cpio with (de)compression on the fly:



                ssh user@host "cd /path/to/files && find . | cpio -ov | bzip2 -c" | bunzip2 -c | cpio -ivd


                Also, find can handle additional conditions, like "files must be less than 4G"



                find . -size -4G | ...


                To make cpio more space-friendly (to handle spaces in file names properly) use



                find . -print0 | cpio -0 -ivd | ...





                share|improve this answer


























                  4














                  I would not recommend using scp for transferring large file trees directly,
                  because it does not handle neither hard nor soft links properly, also the stream is not compressed.



                  I'd recommend cpio with (de)compression on the fly:



                  ssh user@host "cd /path/to/files && find . | cpio -ov | bzip2 -c" | bunzip2 -c | cpio -ivd


                  Also, find can handle additional conditions, like "files must be less than 4G"



                  find . -size -4G | ...


                  To make cpio more space-friendly (to handle spaces in file names properly) use



                  find . -print0 | cpio -0 -ivd | ...





                  share|improve this answer
























                    4












                    4








                    4






                    I would not recommend using scp for transferring large file trees directly,
                    because it does not handle neither hard nor soft links properly, also the stream is not compressed.



                    I'd recommend cpio with (de)compression on the fly:



                    ssh user@host "cd /path/to/files && find . | cpio -ov | bzip2 -c" | bunzip2 -c | cpio -ivd


                    Also, find can handle additional conditions, like "files must be less than 4G"



                    find . -size -4G | ...


                    To make cpio more space-friendly (to handle spaces in file names properly) use



                    find . -print0 | cpio -0 -ivd | ...





                    share|improve this answer












                    I would not recommend using scp for transferring large file trees directly,
                    because it does not handle neither hard nor soft links properly, also the stream is not compressed.



                    I'd recommend cpio with (de)compression on the fly:



                    ssh user@host "cd /path/to/files && find . | cpio -ov | bzip2 -c" | bunzip2 -c | cpio -ivd


                    Also, find can handle additional conditions, like "files must be less than 4G"



                    find . -size -4G | ...


                    To make cpio more space-friendly (to handle spaces in file names properly) use



                    find . -print0 | cpio -0 -ivd | ...






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Dec 10 '12 at 11:39









                    Dmytro Sirenko

                    23614




                    23614

























                        2














                        You don't need to create the tar file before sending it. You can make it on the fly:



                        cd /source/dir
                        tar -cf - . | ssh 'cd /destination/directory && tar -xf -'


                        This does require that the remote server accept ssh shell connections, not just scp connections. In theory, it is possible to send arbitrary file trees to the remote side that don't correspond to anything like the local file structure, but I don't know of any existing tool to do this.



                        If symbolic links are a problem, you can make a copy of a directory tree that doesn't include symbolic links and that uses up negligible space, assuming the source tree is on a filesystem that supports hard links (so any native unix filesystem, or NTFS, but not FAT). I'm assuming GNU utilities here:



                        cd /source/dir
                        mkdir ../regular-files-only
                        cp -al . ../regular-files-only
                        find ../regular-file-only ! -type f ! -type d -delete


                        You could also use sftp. sftp -r does not follow symbolic links, unlike scp -r.






                        share|improve this answer


























                          2














                          You don't need to create the tar file before sending it. You can make it on the fly:



                          cd /source/dir
                          tar -cf - . | ssh 'cd /destination/directory && tar -xf -'


                          This does require that the remote server accept ssh shell connections, not just scp connections. In theory, it is possible to send arbitrary file trees to the remote side that don't correspond to anything like the local file structure, but I don't know of any existing tool to do this.



                          If symbolic links are a problem, you can make a copy of a directory tree that doesn't include symbolic links and that uses up negligible space, assuming the source tree is on a filesystem that supports hard links (so any native unix filesystem, or NTFS, but not FAT). I'm assuming GNU utilities here:



                          cd /source/dir
                          mkdir ../regular-files-only
                          cp -al . ../regular-files-only
                          find ../regular-file-only ! -type f ! -type d -delete


                          You could also use sftp. sftp -r does not follow symbolic links, unlike scp -r.






                          share|improve this answer
























                            2












                            2








                            2






                            You don't need to create the tar file before sending it. You can make it on the fly:



                            cd /source/dir
                            tar -cf - . | ssh 'cd /destination/directory && tar -xf -'


                            This does require that the remote server accept ssh shell connections, not just scp connections. In theory, it is possible to send arbitrary file trees to the remote side that don't correspond to anything like the local file structure, but I don't know of any existing tool to do this.



                            If symbolic links are a problem, you can make a copy of a directory tree that doesn't include symbolic links and that uses up negligible space, assuming the source tree is on a filesystem that supports hard links (so any native unix filesystem, or NTFS, but not FAT). I'm assuming GNU utilities here:



                            cd /source/dir
                            mkdir ../regular-files-only
                            cp -al . ../regular-files-only
                            find ../regular-file-only ! -type f ! -type d -delete


                            You could also use sftp. sftp -r does not follow symbolic links, unlike scp -r.






                            share|improve this answer












                            You don't need to create the tar file before sending it. You can make it on the fly:



                            cd /source/dir
                            tar -cf - . | ssh 'cd /destination/directory && tar -xf -'


                            This does require that the remote server accept ssh shell connections, not just scp connections. In theory, it is possible to send arbitrary file trees to the remote side that don't correspond to anything like the local file structure, but I don't know of any existing tool to do this.



                            If symbolic links are a problem, you can make a copy of a directory tree that doesn't include symbolic links and that uses up negligible space, assuming the source tree is on a filesystem that supports hard links (so any native unix filesystem, or NTFS, but not FAT). I'm assuming GNU utilities here:



                            cd /source/dir
                            mkdir ../regular-files-only
                            cp -al . ../regular-files-only
                            find ../regular-file-only ! -type f ! -type d -delete


                            You could also use sftp. sftp -r does not follow symbolic links, unlike scp -r.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Dec 9 '12 at 23:29









                            Gilles

                            528k12810581583




                            528k12810581583























                                0














                                Another option is to use sftp -r as sftp manual https://www.computerhope.com/unix/sftp.htm says:




                                Recursively copy entire directories when uploading and downloading. Note that sftp does not follow symbolic links encountered in the tree traversal.




                                So



                                sftp -r source@surce_server.com:/source/dir .


                                does exactly what you want to do.






                                share|improve this answer


























                                  0














                                  Another option is to use sftp -r as sftp manual https://www.computerhope.com/unix/sftp.htm says:




                                  Recursively copy entire directories when uploading and downloading. Note that sftp does not follow symbolic links encountered in the tree traversal.




                                  So



                                  sftp -r source@surce_server.com:/source/dir .


                                  does exactly what you want to do.






                                  share|improve this answer
























                                    0












                                    0








                                    0






                                    Another option is to use sftp -r as sftp manual https://www.computerhope.com/unix/sftp.htm says:




                                    Recursively copy entire directories when uploading and downloading. Note that sftp does not follow symbolic links encountered in the tree traversal.




                                    So



                                    sftp -r source@surce_server.com:/source/dir .


                                    does exactly what you want to do.






                                    share|improve this answer












                                    Another option is to use sftp -r as sftp manual https://www.computerhope.com/unix/sftp.htm says:




                                    Recursively copy entire directories when uploading and downloading. Note that sftp does not follow symbolic links encountered in the tree traversal.




                                    So



                                    sftp -r source@surce_server.com:/source/dir .


                                    does exactly what you want to do.







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Dec 18 at 12:13









                                    rRr

                                    1




                                    1






























                                        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.





                                        Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                        Please pay close attention to the following guidance:


                                        • 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%2f58037%2frecursive-scp-without-following-links-or-creating-a-giant-tar-file%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

                                        Morgemoulin

                                        Scott Moir

                                        Souastre