Quantcast
Channel: Oracle, MySQL, Sybase, Informix and other databases
Viewing all articles
Browse latest Browse all 1350

creating back up of database

$
0
0

Hi all

I had created a website and i am able to get backup of database on local system by this code

 protected void ImageBackup_Click(object sender, ImageClickEventArgs e)
    {
        DatabaseBackup("C:/Program Files/MySQL/MySQL Server 5.5/bin/mysqldump.exe", "newpos");
        ClientScript.RegisterStartupScript(this.GetType(), "Key", "alert('Back up has been Successfully created on desktop')", true);
    } public void DatabaseBackup(string ExeLocation, string DBName)
    {
        try
        {
            string tmestr = "";
            tmestr = DBName + "-" + DateTime.Now.ToShortDateString() + ".sql";
            tmestr = tmestr.Replace("/", "-");
            tmestr = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + tmestr;
            StreamWriter file = new StreamWriter(tmestr);
            ProcessStartInfo proc = new ProcessStartInfo();
            string cmd = string.Format(@"-u{0} -p{1} -h{2} {3}", "root", "root", "localhost", DBName);
            proc.FileName = ExeLocation;
            proc.RedirectStandardInput = false;
            proc.RedirectStandardOutput = true;
            proc.Arguments = cmd;
            proc.UseShellExecute = false;
            Process p = Process.Start(proc);
            string res;
            res = p.StandardOutput.ReadToEnd();
            file.WriteLine(res);
            p.WaitForExit();
            file.Close();
        }
        catch (IOException ex)
        {

        }
    }

but when i'm creating back up from website then i'm not able to create backup

so please guide me in creating backup

thanks in advance


Viewing all articles
Browse latest Browse all 1350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>