Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2014
    Posts
    1

    Question Unanswered: MySQL automated query

    Good day all and thanks for you in advance

    I have several IP's "Hosts" that contains several Mysql databases, and am trying to perform the same exact query on all of them as a daily routine automatically

    the query part is ready, am using MySQL using bash command - Cygwin

    the database that I am looking for in each host contains "yesterday" date, so its name is not fixed

    so what I need is to only supply the IP's "hosts" via a separate file to this project like hosts.csv, and make it automatically run the query on the databases of each host that contains yesterday date, the output can be one file or separate files its not an issue

    will this be applicable? and if yes how can I do it,

    many thanks again

  2. #2
    Join Date
    Jul 2011
    Location
    INDIA
    Posts
    6

    Reply

    any automatic process on a computer is and should be done by the
    operating system alone and no one else.
    what you can do is write the script which doe's the backup and then save it as an .bat file on windows and attach it to an process which executes at an different intervals.
    if you are on the Linux i'm sorry i don't know

    i use one it creates the backup and then it compress the file and save it as the
    password protected compressed winrar file

  3. #3
    Join Date
    Jul 2011
    Location
    INDIA
    Posts
    6

    my reply

    any automatic process on a computer is and should be done by the
    operating system alone and no one else.
    what you can do is write the script which doe's the backup and then save it as an .bat file on windows and attach it to an process which executes at an different intervals.
    if you are on the Linux i'm sorry i don't know

    i use one it creates the backup and then it compress the file and save it as the
    password protected compressed winrar file

  4. #4
    Join Date
    Jul 2011
    Location
    INDIA
    Posts
    6

    code

    PHP Code:
    @echo off

     
    setlocal
    set mysql_username
    ="root"
    set mysql_password="***********"
    set mysql_path="C:\Program Files\MySQL\MySQL Server 5.5\bin"
    set zip_path="7za.exe"
    set ErrorNote=""

     
     
    for /"delims=" %%a in (dump.txt) do set "variable=%%a"
    set variable=%variable:prefix =%
    set output_path=%variable%


    REM Start of Script.
    IF 
    NOT EXIST %output_path% (mkdir %output_path%)

    IF 
    NOT EXIST 7za.exe GOTO CompressionFailure 
       
     
    IF NOT EXIST dump.txt GOTO DumpFailure
       


    :dump_and_zip:
        
    REM Dump out the MySQL Database to a timestamped .sql file
        
    for /"tokens=1,2,3 delims=/ " %%a in ('DATE /T') do set date=%%c-%%b-%%a
        
    for /"tokens=1,2 delims=:" %%a in ('TIME /T') do set time=%%a-%%b
        
      
         
    @ECHO ON
        
    @ECHO Processing POARES backUp ......
        @ECHO *******************************
        @ECHO 
    Creating BackUp at
        
    @ECHO %output_path%
        @ECHO *                 *
        @ECHO *                             *
        @ECHO 
    PLEASE WAIT TILL PROCESS COMPLETES
        
    @ECHO *                                                * 
        @ECHO 
    Contact Information On failure
        
    @ECHO ------------------------------
        @ECHO 
    Balasubramanya
        
    @ECHO LP UBL
        
    @ECHO 9731646315
        
    @ECHO Please Prefer to Send SMS with Error Details
        
    @ECHO *                                          *
        @ECHO 
    OFF

         
    REM mysqldump 
    -u root --<db-host> --opt <db-name> ---single-transaction sed 's/ AUTO_INCREMENT=[0-9]*\b//' > <filename>.sql
                                           
     
    "C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump.exe" --user %mysql_username% --password=%mysql_password% --routines sed 's/ AUTO_INCREMENT=[0-9]*\b//'   --result-file="%output_path%\%date%_%time%.sql" rfx220
     
        
        REM Check 
    for Errors.
        if %
    ERRORLEVELNEQ 0 (goto error)
           
         @ECHO 
    ON

          
    @ECHO *                            *
          @ECHO 
    Writing to Disk Under Progress ...
          @ECHO *                            * 
          @ECHO 
    OFF

      
        REM Zip it up 
    and remove the temp file.
        
    REM 7za a rfx3.7z --15-11-2013_21-41.sql -pSECRET

        7za a 
    %output_path%\%date%_%time%POR.7z  "%output_path%\%date%_%time%.sql" -pmakemerain

        del 
    "%output_path%\%date%_%time%.sql"
        
    goto :EOF

    :CompressionFailure
    @ECHO Compression tool failureApplication Filed to Continue
    EXIT /
    B 42

    :DumpFailure
    @ECHO Dump path failureApplication Filed to Continue
     EXIT /
    B 42
         
    :error
        
    echo An error occured.
    PAUSE
        
    EXIT /B 42
         
    :end
        endlocal

    @ECHO POARES BackUp completed

    PAUSE 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •