Writing a script to rsync all directories












1















I have a huge set of backup files, each containing a directory of Videos. Each video directory is slightly different. I would like to merge these into a single directory to conserve, as I don't really care about which backup each Video came from.



To do this, I figure that rsync would be the best tool but I'm having difficulty coming up with a nice clean script to rsync each backup's Video directory with an outside destination.



In other words, I want a script that will automate the following process



rsync -a ./Backups/Backup-x/Videos/ ./CollectedVideos/
rsync -a ./Backups/Backup-y/Videos/ ./CollectedVideos/
rsync -a ./Backups/Backup-z/Videos/ ./CollectedVideos/
rsync -a ./Backups/Backup-t/Videos/ ./CollectedVideos/


Where all files in the Backups/ directory are "fair game."



Any suggestions would be appreciated.










share|improve this question



























    1















    I have a huge set of backup files, each containing a directory of Videos. Each video directory is slightly different. I would like to merge these into a single directory to conserve, as I don't really care about which backup each Video came from.



    To do this, I figure that rsync would be the best tool but I'm having difficulty coming up with a nice clean script to rsync each backup's Video directory with an outside destination.



    In other words, I want a script that will automate the following process



    rsync -a ./Backups/Backup-x/Videos/ ./CollectedVideos/
    rsync -a ./Backups/Backup-y/Videos/ ./CollectedVideos/
    rsync -a ./Backups/Backup-z/Videos/ ./CollectedVideos/
    rsync -a ./Backups/Backup-t/Videos/ ./CollectedVideos/


    Where all files in the Backups/ directory are "fair game."



    Any suggestions would be appreciated.










    share|improve this question

























      1












      1








      1








      I have a huge set of backup files, each containing a directory of Videos. Each video directory is slightly different. I would like to merge these into a single directory to conserve, as I don't really care about which backup each Video came from.



      To do this, I figure that rsync would be the best tool but I'm having difficulty coming up with a nice clean script to rsync each backup's Video directory with an outside destination.



      In other words, I want a script that will automate the following process



      rsync -a ./Backups/Backup-x/Videos/ ./CollectedVideos/
      rsync -a ./Backups/Backup-y/Videos/ ./CollectedVideos/
      rsync -a ./Backups/Backup-z/Videos/ ./CollectedVideos/
      rsync -a ./Backups/Backup-t/Videos/ ./CollectedVideos/


      Where all files in the Backups/ directory are "fair game."



      Any suggestions would be appreciated.










      share|improve this question














      I have a huge set of backup files, each containing a directory of Videos. Each video directory is slightly different. I would like to merge these into a single directory to conserve, as I don't really care about which backup each Video came from.



      To do this, I figure that rsync would be the best tool but I'm having difficulty coming up with a nice clean script to rsync each backup's Video directory with an outside destination.



      In other words, I want a script that will automate the following process



      rsync -a ./Backups/Backup-x/Videos/ ./CollectedVideos/
      rsync -a ./Backups/Backup-y/Videos/ ./CollectedVideos/
      rsync -a ./Backups/Backup-z/Videos/ ./CollectedVideos/
      rsync -a ./Backups/Backup-t/Videos/ ./CollectedVideos/


      Where all files in the Backups/ directory are "fair game."



      Any suggestions would be appreciated.







      bash scripts backup rsync






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jul 31 '14 at 1:33









      neanderslobneanderslob

      4211520




      4211520






















          2 Answers
          2






          active

          oldest

          votes


















          2














          If at least one of the folders in ./Backups contains a Video directory,



          for dir in ./Backups/*/Videos
          do
          if [[ -d $dir ]]
          then
          rsync -a $dir/* ./CollectedVideos/
          fi
          done


          might be close to what you are looking for.



          The /* after $dir is important to copy the files without including their directory.






          share|improve this answer

































            0














            Did using wildcards not work:?
            rsync -a backup//Videos/ /
            The other way is to use find and xargs:
            find backups/Backup-*/ -type f -name ""| xargs -I {} -n 1 rsync {} /
            Of course, find is a very slow running command






            share|improve this answer























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "89"
              };
              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%2faskubuntu.com%2fquestions%2f504792%2fwriting-a-script-to-rsync-all-directories%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














              If at least one of the folders in ./Backups contains a Video directory,



              for dir in ./Backups/*/Videos
              do
              if [[ -d $dir ]]
              then
              rsync -a $dir/* ./CollectedVideos/
              fi
              done


              might be close to what you are looking for.



              The /* after $dir is important to copy the files without including their directory.






              share|improve this answer






























                2














                If at least one of the folders in ./Backups contains a Video directory,



                for dir in ./Backups/*/Videos
                do
                if [[ -d $dir ]]
                then
                rsync -a $dir/* ./CollectedVideos/
                fi
                done


                might be close to what you are looking for.



                The /* after $dir is important to copy the files without including their directory.






                share|improve this answer




























                  2












                  2








                  2







                  If at least one of the folders in ./Backups contains a Video directory,



                  for dir in ./Backups/*/Videos
                  do
                  if [[ -d $dir ]]
                  then
                  rsync -a $dir/* ./CollectedVideos/
                  fi
                  done


                  might be close to what you are looking for.



                  The /* after $dir is important to copy the files without including their directory.






                  share|improve this answer















                  If at least one of the folders in ./Backups contains a Video directory,



                  for dir in ./Backups/*/Videos
                  do
                  if [[ -d $dir ]]
                  then
                  rsync -a $dir/* ./CollectedVideos/
                  fi
                  done


                  might be close to what you are looking for.



                  The /* after $dir is important to copy the files without including their directory.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jul 31 '14 at 2:24

























                  answered Jul 31 '14 at 1:53









                  murumuru

                  1




                  1

























                      0














                      Did using wildcards not work:?
                      rsync -a backup//Videos/ /
                      The other way is to use find and xargs:
                      find backups/Backup-*/ -type f -name ""| xargs -I {} -n 1 rsync {} /
                      Of course, find is a very slow running command






                      share|improve this answer




























                        0














                        Did using wildcards not work:?
                        rsync -a backup//Videos/ /
                        The other way is to use find and xargs:
                        find backups/Backup-*/ -type f -name ""| xargs -I {} -n 1 rsync {} /
                        Of course, find is a very slow running command






                        share|improve this answer


























                          0












                          0








                          0







                          Did using wildcards not work:?
                          rsync -a backup//Videos/ /
                          The other way is to use find and xargs:
                          find backups/Backup-*/ -type f -name ""| xargs -I {} -n 1 rsync {} /
                          Of course, find is a very slow running command






                          share|improve this answer













                          Did using wildcards not work:?
                          rsync -a backup//Videos/ /
                          The other way is to use find and xargs:
                          find backups/Backup-*/ -type f -name ""| xargs -I {} -n 1 rsync {} /
                          Of course, find is a very slow running command







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Dec 9 '18 at 9:22









                          tpb261tpb261

                          101




                          101






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Ask Ubuntu!


                              • 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%2faskubuntu.com%2fquestions%2f504792%2fwriting-a-script-to-rsync-all-directories%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 change which sound is reproduced for terminal bell?

                              Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

                              Can I use Tabulator js library in my java Spring + Thymeleaf project?