Shell script fails to create a mysql backupHow do you change the default shell for ALL USERS to bash?How to take daily backup of database?What is the best way to use the mysql charm in Juju with dynamic database credientials?grant command syntax error near password in shell scriptHow can I get mysqldump to use the credentials from mysql_config_editor in a crontab-executed script?Terminal crashes when running lsblk -hDelete oldest file in a directory, when there are more than 7 files?Php script does not connect to MySQL (Vagrant VM)Unable to insert in table in database in mysql using phpHow do I start and stop a systemctl service inside a bash script?

When did Linux kernel become libre software?

Confusion about off peak timings of London trains

Can the poison from Kingsmen be concocted?

What is the advantage of carrying a tripod and ND-filters when you could use image stacking instead?

Smooth switching between 12 V batteries, with a toggle switch

Was the Tamarian language in "Darmok" inspired by Jack Vance's "The Asutra"?

Efficient integer floor function in C++

What is the giant octopus in the torture chamber for?

"You've got another thing coming" - translation into French

Why doesn’t a normal window produce an apparent rainbow?

What risks are there when you clear your cookies instead of logging off?

How do governments keep track of their issued currency?

Did the ending really happen in Baby Driver?

How much salt (or any other substance one can find in a kitchen) do I need to add to make water boil at 104 °C?

Does a 3rd-level Wolf Totem barbarian get advantage against enemies when an ally is within 5 feet of the enemy?

How to project 3d image in the planes xy, xz, yz?

What's the name of this light airplane?

Magento 2: PWA sample data installation error

Are "living" organ banks practical?

Should an arbiter claim draw at a K+R vs K+R endgame?

How did they achieve the Gunslinger's shining eye effect in Westworld?

Indirectly defined macros: Undefined macro with "@" does not trigger compile error

What's up with this leaf?

Why does the Schrödinger equation work so well for the hydrogen atom despite the relativistic boundary at the nucleus?



Shell script fails to create a mysql backup


How do you change the default shell for ALL USERS to bash?How to take daily backup of database?What is the best way to use the mysql charm in Juju with dynamic database credientials?grant command syntax error near password in shell scriptHow can I get mysqldump to use the credentials from mysql_config_editor in a crontab-executed script?Terminal crashes when running lsblk -hDelete oldest file in a directory, when there are more than 7 files?Php script does not connect to MySQL (Vagrant VM)Unable to insert in table in database in mysql using phpHow do I start and stop a systemctl service inside a bash script?






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








2















I want to create a shell script to automatically backup MySQL DB. I will later copy it to an s3 bucket.



I have created the following shell script:



#vim /home/ubuntu/backup/mysqlbackup.sh

#!/bin/bash
## Specify the name of the database that you want to backupbackup

# Database credentials
USER="user1"
PASSWORD="password"
HOST="hostname.compute.amazonaws.com"
DB_NAME="db1"

#Backup_Directory_Locations
BACKUPROOT="/home/ubuntu/backup"
TSTAMP=$(date +"%d-%b-%Y-%H-%M-%S")
S3BUCKET="s3://s3bucket"
#LOG_FILE="/home/ubuntu/backup/log/dump.log"

mysqldump -h <HOST> -u <USER> --database <DB_NAME> -p"$PASSWORD" > $BACKUPROOT/$DB_NAME-$TSTAMP.sql


Then from the command line, I run the script:



sudo bash -x ./mysqlbackup.sh


And it fails, telling me:




HOST: No such file or directory




enter image description here










share|improve this question




























    2















    I want to create a shell script to automatically backup MySQL DB. I will later copy it to an s3 bucket.



    I have created the following shell script:



    #vim /home/ubuntu/backup/mysqlbackup.sh

    #!/bin/bash
    ## Specify the name of the database that you want to backupbackup

    # Database credentials
    USER="user1"
    PASSWORD="password"
    HOST="hostname.compute.amazonaws.com"
    DB_NAME="db1"

    #Backup_Directory_Locations
    BACKUPROOT="/home/ubuntu/backup"
    TSTAMP=$(date +"%d-%b-%Y-%H-%M-%S")
    S3BUCKET="s3://s3bucket"
    #LOG_FILE="/home/ubuntu/backup/log/dump.log"

    mysqldump -h <HOST> -u <USER> --database <DB_NAME> -p"$PASSWORD" > $BACKUPROOT/$DB_NAME-$TSTAMP.sql


    Then from the command line, I run the script:



    sudo bash -x ./mysqlbackup.sh


    And it fails, telling me:




    HOST: No such file or directory




    enter image description here










    share|improve this question
























      2












      2








      2








      I want to create a shell script to automatically backup MySQL DB. I will later copy it to an s3 bucket.



      I have created the following shell script:



      #vim /home/ubuntu/backup/mysqlbackup.sh

      #!/bin/bash
      ## Specify the name of the database that you want to backupbackup

      # Database credentials
      USER="user1"
      PASSWORD="password"
      HOST="hostname.compute.amazonaws.com"
      DB_NAME="db1"

      #Backup_Directory_Locations
      BACKUPROOT="/home/ubuntu/backup"
      TSTAMP=$(date +"%d-%b-%Y-%H-%M-%S")
      S3BUCKET="s3://s3bucket"
      #LOG_FILE="/home/ubuntu/backup/log/dump.log"

      mysqldump -h <HOST> -u <USER> --database <DB_NAME> -p"$PASSWORD" > $BACKUPROOT/$DB_NAME-$TSTAMP.sql


      Then from the command line, I run the script:



      sudo bash -x ./mysqlbackup.sh


      And it fails, telling me:




      HOST: No such file or directory




      enter image description here










      share|improve this question














      I want to create a shell script to automatically backup MySQL DB. I will later copy it to an s3 bucket.



      I have created the following shell script:



      #vim /home/ubuntu/backup/mysqlbackup.sh

      #!/bin/bash
      ## Specify the name of the database that you want to backupbackup

      # Database credentials
      USER="user1"
      PASSWORD="password"
      HOST="hostname.compute.amazonaws.com"
      DB_NAME="db1"

      #Backup_Directory_Locations
      BACKUPROOT="/home/ubuntu/backup"
      TSTAMP=$(date +"%d-%b-%Y-%H-%M-%S")
      S3BUCKET="s3://s3bucket"
      #LOG_FILE="/home/ubuntu/backup/log/dump.log"

      mysqldump -h <HOST> -u <USER> --database <DB_NAME> -p"$PASSWORD" > $BACKUPROOT/$DB_NAME-$TSTAMP.sql


      Then from the command line, I run the script:



      sudo bash -x ./mysqlbackup.sh


      And it fails, telling me:




      HOST: No such file or directory




      enter image description here







      command-line bash mysql






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked May 21 at 1:24









      Hooman BahreiniHooman Bahreini

      1747




      1747




















          1 Answer
          1






          active

          oldest

          votes


















          16














          <HOST>. <DB_NAME> etc, are just placeholders.



          They should be replaced by actual strings or shell variable expansions "$HOST", "$DB_NAME" and so on - just as you have done with -p"$PASSWORD"



          The error message is because < and > are redirection operators.






          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%2f1144917%2fshell-script-fails-to-create-a-mysql-backup%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            16














            <HOST>. <DB_NAME> etc, are just placeholders.



            They should be replaced by actual strings or shell variable expansions "$HOST", "$DB_NAME" and so on - just as you have done with -p"$PASSWORD"



            The error message is because < and > are redirection operators.






            share|improve this answer



























              16














              <HOST>. <DB_NAME> etc, are just placeholders.



              They should be replaced by actual strings or shell variable expansions "$HOST", "$DB_NAME" and so on - just as you have done with -p"$PASSWORD"



              The error message is because < and > are redirection operators.






              share|improve this answer

























                16












                16








                16







                <HOST>. <DB_NAME> etc, are just placeholders.



                They should be replaced by actual strings or shell variable expansions "$HOST", "$DB_NAME" and so on - just as you have done with -p"$PASSWORD"



                The error message is because < and > are redirection operators.






                share|improve this answer













                <HOST>. <DB_NAME> etc, are just placeholders.



                They should be replaced by actual strings or shell variable expansions "$HOST", "$DB_NAME" and so on - just as you have done with -p"$PASSWORD"



                The error message is because < and > are redirection operators.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered May 21 at 1:28









                steeldriversteeldriver

                73.5k11121197




                73.5k11121197



























                    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%2f1144917%2fshell-script-fails-to-create-a-mysql-backup%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 write a 12-bar blues melodyI-IV-V blues progressionHow to play the bridges in a standard blues progressionHow does Gdim7 fit in C# minor?question on a certain chord progressionMusicology of Melody12 bar blues, spread rhythm: alternative to 6th chord to avoid finger stretchChord progressions/ Root key/ MelodiesHow to put chords (POP-EDM) under a given lead vocal melody (starting from a good knowledge in music theory)Are there “rules” for improvising with the minor pentatonic scale over 12-bar shuffle?Confusion about blues scale and chords

                    What if the end-user didn't have the required library?What is setup.py?What is a clean, pythonic way to have multiple constructors in Python?What does Ruby have that Python doesn't, and vice versa?What is the reason for having '//' in Python?How do I create a namespace package in Python?How to package shared objects that python modules depend on?setuptools vs. distutils: why is distutils still a thing?Navigation in Windows 10 vs code not going to virtualenv library when the same library is installed at user levelPython create package for local usePackaging a project that uses multiple python versionsWhy is permission denied on pip install except for when “--user” is included at end of command?

                    Esgonzo ibérico Índice Descrición Distribución Hábitat Ameazas Notas Véxase tamén "Acerca dos nomes dos anfibios e réptiles galegos""Chalcides bedriagai"Chalcides bedriagai en Carrascal, L. M. Salvador, A. (Eds). Enciclopedia virtual de los vertebrados españoles. Museo Nacional de Ciencias Naturales, Madrid. España.Fotos