C# Oracle Backup

 private void btnBackupDB_Click(object sender, EventArgs e)
            //## Settings
            //Path to store the oracle dump
            string path = @"C:\backup";
            string backupFileName = "mybackup.dmp";
            //your ORACLE_HOME enviroment variable must be setted or you need to set the path here:
            string oracleHome = Environment.GetEnvironmentVariable("ORACLE_HOME");
            string oracleUser = "sys";
            string oraclePassword = "abc";
            string oracleSID = "xe";

            ProcessStartInfo psi = new ProcessStartInfo();
            //Exp is the tool used to export data.
            //this tool is inside $ORACLE_HOME\bin directory
            psi.FileName = Path.Combine(oracleHome, "bin", "exp");
            psi.RedirectStandardInput = false;
            psi.RedirectStandardOutput = true;
            string dumpFile = Path.Combine(path, backupFileName);
            //The command line is: exp user/password@database file=backupname.dmp [OPTIONS....]
            psi.Arguments = string.Format(oracleUser + "/" + oraclePassword + "@" + oracleSID + " FULL=y FILE=" + dumpFile);
            psi.UseShellExecute = false;
            Process process = Process.Start(psi);
            MessageBox.Show("Database Backup Completed Successfully");

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s