Wget - try series of backup links












0















How can I get wget (possibly with help from a bash script) to try a series of mirrors if a site is down (or times out part way through downloading)? For example, first try download https://www.example.com/file.gz, then if that fails try https://mirror1.example.com/file.gz, then https://another.example.com/file.gz?










share|improve this question



























    0















    How can I get wget (possibly with help from a bash script) to try a series of mirrors if a site is down (or times out part way through downloading)? For example, first try download https://www.example.com/file.gz, then if that fails try https://mirror1.example.com/file.gz, then https://another.example.com/file.gz?










    share|improve this question

























      0












      0








      0








      How can I get wget (possibly with help from a bash script) to try a series of mirrors if a site is down (or times out part way through downloading)? For example, first try download https://www.example.com/file.gz, then if that fails try https://mirror1.example.com/file.gz, then https://another.example.com/file.gz?










      share|improve this question














      How can I get wget (possibly with help from a bash script) to try a series of mirrors if a site is down (or times out part way through downloading)? For example, first try download https://www.example.com/file.gz, then if that fails try https://mirror1.example.com/file.gz, then https://another.example.com/file.gz?







      wget mirroring






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 11 at 15:00









      Chris JeffersonChris Jefferson

      1083




      1083






















          2 Answers
          2






          active

          oldest

          votes


















          2














          Try this:



          #!/bin/sh
          for site in www.example.com mirror1.example.com another.mirror.com
          do
          wget --timeout=60 --continue $site/file.gz && break
          done


          The --continue switch allows you to pickup downloading where the last site left off.



          Note that you can separately set --dns-timeout, --connect-timeout and --read-timeout if wanted.






          share|improve this answer































            0














            Ken Jackson's answer is spot on about how you would do this. However, I'm going to assume here that you already have all the links in a single separate file. In this case, you don't really need any bash scripts to do the job. You can simply run:



            $ wget --timeout=60 --tries=1 --continue --input-file <inputfile>


            For a nice looking output, I also use -q --show-progress which will force Wget to display only the progress bars and nothing else.



            What the above command does is it tries to download every link from the file you gave it. However, after the entire file is downloaded, it will simply query each server, realise the file already exists and then move on. It wastes a very tiny amount of extra bandwidth, but is far easier to type in and doesn't need to multiple invokations of the binary.






            share|improve this answer
























              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%2f1404465%2fwget-try-series-of-backup-links%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              2














              Try this:



              #!/bin/sh
              for site in www.example.com mirror1.example.com another.mirror.com
              do
              wget --timeout=60 --continue $site/file.gz && break
              done


              The --continue switch allows you to pickup downloading where the last site left off.



              Note that you can separately set --dns-timeout, --connect-timeout and --read-timeout if wanted.






              share|improve this answer




























                2














                Try this:



                #!/bin/sh
                for site in www.example.com mirror1.example.com another.mirror.com
                do
                wget --timeout=60 --continue $site/file.gz && break
                done


                The --continue switch allows you to pickup downloading where the last site left off.



                Note that you can separately set --dns-timeout, --connect-timeout and --read-timeout if wanted.






                share|improve this answer


























                  2












                  2








                  2







                  Try this:



                  #!/bin/sh
                  for site in www.example.com mirror1.example.com another.mirror.com
                  do
                  wget --timeout=60 --continue $site/file.gz && break
                  done


                  The --continue switch allows you to pickup downloading where the last site left off.



                  Note that you can separately set --dns-timeout, --connect-timeout and --read-timeout if wanted.






                  share|improve this answer













                  Try this:



                  #!/bin/sh
                  for site in www.example.com mirror1.example.com another.mirror.com
                  do
                  wget --timeout=60 --continue $site/file.gz && break
                  done


                  The --continue switch allows you to pickup downloading where the last site left off.



                  Note that you can separately set --dns-timeout, --connect-timeout and --read-timeout if wanted.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Feb 11 at 15:31









                  Ken JacksonKen Jackson

                  22112




                  22112

























                      0














                      Ken Jackson's answer is spot on about how you would do this. However, I'm going to assume here that you already have all the links in a single separate file. In this case, you don't really need any bash scripts to do the job. You can simply run:



                      $ wget --timeout=60 --tries=1 --continue --input-file <inputfile>


                      For a nice looking output, I also use -q --show-progress which will force Wget to display only the progress bars and nothing else.



                      What the above command does is it tries to download every link from the file you gave it. However, after the entire file is downloaded, it will simply query each server, realise the file already exists and then move on. It wastes a very tiny amount of extra bandwidth, but is far easier to type in and doesn't need to multiple invokations of the binary.






                      share|improve this answer




























                        0














                        Ken Jackson's answer is spot on about how you would do this. However, I'm going to assume here that you already have all the links in a single separate file. In this case, you don't really need any bash scripts to do the job. You can simply run:



                        $ wget --timeout=60 --tries=1 --continue --input-file <inputfile>


                        For a nice looking output, I also use -q --show-progress which will force Wget to display only the progress bars and nothing else.



                        What the above command does is it tries to download every link from the file you gave it. However, after the entire file is downloaded, it will simply query each server, realise the file already exists and then move on. It wastes a very tiny amount of extra bandwidth, but is far easier to type in and doesn't need to multiple invokations of the binary.






                        share|improve this answer


























                          0












                          0








                          0







                          Ken Jackson's answer is spot on about how you would do this. However, I'm going to assume here that you already have all the links in a single separate file. In this case, you don't really need any bash scripts to do the job. You can simply run:



                          $ wget --timeout=60 --tries=1 --continue --input-file <inputfile>


                          For a nice looking output, I also use -q --show-progress which will force Wget to display only the progress bars and nothing else.



                          What the above command does is it tries to download every link from the file you gave it. However, after the entire file is downloaded, it will simply query each server, realise the file already exists and then move on. It wastes a very tiny amount of extra bandwidth, but is far easier to type in and doesn't need to multiple invokations of the binary.






                          share|improve this answer













                          Ken Jackson's answer is spot on about how you would do this. However, I'm going to assume here that you already have all the links in a single separate file. In this case, you don't really need any bash scripts to do the job. You can simply run:



                          $ wget --timeout=60 --tries=1 --continue --input-file <inputfile>


                          For a nice looking output, I also use -q --show-progress which will force Wget to display only the progress bars and nothing else.



                          What the above command does is it tries to download every link from the file you gave it. However, after the entire file is downloaded, it will simply query each server, realise the file already exists and then move on. It wastes a very tiny amount of extra bandwidth, but is far easier to type in and doesn't need to multiple invokations of the binary.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Feb 11 at 18:17









                          darnirdarnir

                          613518




                          613518






























                              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%2f1404465%2fwget-try-series-of-backup-links%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

                              How to make a Squid Proxy server?

                              第一次世界大戦

                              Touch on Surface Book