kwangu

VB BACKUP CODE

Jun 15th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.31 KB | None | 0 0
  1. Sub CreateBackup()
  2.         Dim mysqldumpPath As String = "C:\wamp\bin\mysql\mysql5.6.17\bin\mysqldump.exe"
  3.         Dim host As String = "localhost"
  4.         Dim user As String = "root"
  5.         Dim pswd As String = ""
  6.         Dim dbnm As String = "switchcity"
  7.         Dim cmd As String = String.Format("-h{0} -u{1} -p{2} {3}", host, user, pswd, dbnm)
  8.         Dim filePath As String = "F:\backup\switchDB.sql"
  9.         OutputStream = New System.IO.StreamWriter(filePath, False, System.Text.Encoding.UTF8)
  10.  
  11.         Dim startInfo As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo()
  12.         startInfo.FileName = mysqldumpPath
  13.         startInfo.Arguments = cmd
  14.  
  15.         startInfo.RedirectStandardError = True
  16.         startInfo.RedirectStandardInput = False
  17.         startInfo.RedirectStandardOutput = True
  18.         startInfo.UseShellExecute = False
  19.         startInfo.CreateNoWindow = True
  20.         startInfo.ErrorDialog = False
  21.  
  22.         Dim proc As System.Diagnostics.Process = New System.Diagnostics.Process()
  23.         proc.StartInfo = startInfo
  24.         AddHandler proc.OutputDataReceived, AddressOf OnDataReceived1
  25.         proc.Start()
  26.         proc.BeginOutputReadLine()
  27.         proc.WaitForExit()
  28.  
  29.         OutputStream.Flush()
  30.         OutputStream.Close()
  31.         proc.Close()
  32.     End Sub
Add Comment
Please, Sign In to add comment