1 (edited by prahousefamily 2017-07-18 04:21:01)

Topic: Example MVD + MySQLDump.exe +Gzip Update 2017-07-18

For Basic Create .Bat For use CMD Combine mysqldump.exe
backup & restore mysql database

https://s9.postimg.org/y65x5zrdr/2017-07-17_14_56_55.png

Post's attachments

Attachment icon MySQLDumpTool.zip 813.12 kb, 562 downloads since 2017-07-17 

My Visual Database : I Love You
Easy For Beginner Student For Me

Re: Example MVD + MySQLDump.exe +Gzip Update 2017-07-18

Thanks!

Dmitry.

3 (edited by prahousefamily 2017-07-18 04:30:54)

Re: Example MVD + MySQLDump.exe +Gzip Update 2017-07-18

Update 2017-07-18
- Add Date Time Function in .bat file
- Compress File gzip
Example Screen
https://s10.postimg.org/uwku0u2u1/2017-07-18_11_09_11.png
Source Code Open

var
AppPath : String;
procedure Form1_Button3_OnClick (Sender: string; var Cancel: boolean);
begin
    OpenFile(AppPath+'backup.bat','')
end;
procedure Form1_Button1_OnClick (Sender: string; var Cancel: boolean);
var
MySQL: TMyConnection;
qd : Tdataset ;
begin     
    MySQL := TMyConnection.Create(Form1);
    MySQL.Options.UseUnicode := True;
    MySQL.Server := Form1.Edit1.Text ;
    MySQL.Port := StrtoInt(Form1.Edit4.Text);
    MySQL.Username := Form1.Edit2.Text ;
    MySQL.Password := Form1.Edit3.Text ;
    // MySQL.Database := Form1.Edit5.Text ;
    MySQL.LoginPromt := False;
    try
        MySQL.Connect;
        except
        ShowMessage('Can''t connect to database.');
    end;
    if MySQL.Connected then
    begin
        ShowMessage('OK connect to database.');
        SQLQuery('Show databases',qd) ;
        Form1.ComboBox1.Clear;
        while not qd.eof do begin
            Form1.ComboBox1.Items.Add(qd.fields.fields[0].asstring);
            qd.next;
        end;
        qd.close;
        MySQL.Disconnect;
    end;
end;
procedure Form1_Button2_OnClick (Sender: string; var Cancel: boolean);
begin
    Form1.Memo1.Clear ;
    Form1.Memo1.lines.Add('title Please Wait! MySQLDump Processing Data');
    Form1.Memo1.lines.Add('set year=%DATE:~10,4%');
    Form1.Memo1.lines.Add('set day=%DATE:~7,2%');
    Form1.Memo1.lines.Add('set mnt=%DATE:~4,2%');
    Form1.Memo1.lines.Add('set hr=%TIME:~0,2%');
    Form1.Memo1.lines.Add('set min=%TIME:~3,2%');
    Form1.Memo1.lines.Add('IF %day% LSS 10 SET day=0%day:~1,1%');
    Form1.Memo1.lines.Add('IF %mnt% LSS 10 SET mnt=0%mnt:~1,1%');
    Form1.Memo1.lines.Add('IF %hr% LSS 10 SET hr=0%hr:~1,1%');
    Form1.Memo1.lines.Add('IF %min% LSS 10 SET min=0%min:~1,1%');
    Form1.Memo1.lines.Add('set SS=%TIME:~6,2%');
    Form1.Memo1.lines.Add('set backuptime=%year%%mnt%%day%%hr%%min%%SS%');
    Form1.Memo1.lines.Add('set dbname='+Form1.ComboBox1.Text);
    Form1.Memo1.lines.Add('set dbuser='+Form1.Edit2.Text );
    Form1.Memo1.lines.Add('set dbpass='+Form1.Edit3.Text );
    Form1.Memo1.lines.Add('set dbhost='+Form1.Edit1.Text );
    Form1.Memo1.lines.Add('set dbport='+Form1.Edit4.Text );
    Form1.Memo1.lines.Add('set dbdump='+Apppath+'bin\mysqldump.exe' );
    Form1.Memo1.lines.Add('set pathbackup='+Apppath+'backupfiles\' );
    Form1.Memo1.lines.Add('set expsql='+Apppath+'backupfiles\' );
    Form1.Memo1.lines.Add('set gzipexe='+Apppath+'bin\gzip.exe' );
    Form1.Memo1.lines.Add
    ('%dbdump% --extended-insert=FALSE --skip-comments -u%dbuser% -p%dbpass% -h%dbhost% -P%dbport%  %dbname% > "%expsql%%dbname% %backuptime%.sql"');
    Form1.Memo1.lines.Add('cd %pathbackup%');
    Form1.Memo1.lines.Add('%gzipexe% "%dbname% %backuptime%.sql"');
    Form1.Memo1.lines.Add('start %expsql%');
    Form1.Memo1.Lines.SaveToFile(AppPath+'backup.bat');
    ShowMessage('Ready OK!');
end;
begin
    AppPath := ExtractFilePath(Application.ExeName);
    Form1.mniFile.Visible := False;
    Form1.mniOptions.Visible := False;
    Form1.mniSettings.Visible := False;
    Form1.mniReport.Visible:= False;
    Form1.mniAbout.Visible := False;
end.

Reference : https://jonlabelle.com/snippets/view/do … bat-script

Post's attachments

Attachment icon MySQLDumpToolFix002.zip 860.3 kb, 660 downloads since 2017-07-18 

My Visual Database : I Love You
Easy For Beginner Student For Me