Oracle backup and restoration operations

Source: Internet
Author: User
1 # Region/* Backup and restoration operations */
/// <Summary>
/// Backup
/// </Summary>
/// <Param name = "username"> User Name </param>
/// <Param name = "PWD"> password </param>
/// <Param name = "dbserver"> database </param>
/// <Param name = "pathname"> path </param>
/// <Param name = "databasefilename"> Backup file name </param>
/// <Param name = "appendcommand"> Backup parameter </param>
/// <Param name = "LOGNAME"> log file name </param>
/// <Returns> </returns>
Public bool backuporacledatabase (string username, string PWD, string dbserver, string pathname, string databasefilename, string appendcommand, string LOGNAME, string sqltextconfig)
{
This. sqltextfilename = pathname + "\" + sqltextconfig;
# Region/* xmlsql corner generation */
If (file. exists (sqltextfilename ))
{
File. Delete (sqltextfilename );
}
// Backup database information
Dbentity = new dbentity ();
Dbentity. dbserver = dbserver;
Dbentity. Username = username;
Dbentity. Pwd = PWD;
Writexmluserspaceconfig (dbentity );
# Endregion
// Exp userid = system/zhice @ JC full = y indexes = n grants = y rows = y compress = n file = D: \ demo. DMP log = D: \ demo. log
String loginstring = string. Format ("userid = {0}/{1} @ {2}", username, PWD, dbserver );
String filename = "exp ";
String arguments = string. format ("{0} full = y file = {1} log = {2}", loginstring, pathname + "\" + databasefilename, pathname + "\" + LOGNAME );
String backupcommand = string. Format ("{0} {1}", filename, arguments );
Try
{
System. Diagnostics. Process bakupprocess = new system. Diagnostics. Process ();
Bakupprocess. startinfo. filename = filename;
Bakupprocess. startinfo. Arguments = arguments;
Bakupprocess. Start ();
Return true;
}
Catch (exception ex)
{
System. Diagnostics. Debug. writeline (Ex );
Return false;
}
}
/// <Summary>
/// Restore
/// </Summary>
/// <Param name = "username"> User Name </param>
/// <Param name = "PWD"> password </param>
/// <Param name = "dbserver"> database </param>
/// <Param name = "pathname"> path </param>
/// <Param name = "databasefilename"> Backup file name </param>
/// <Param name = "appendcommand"> Backup parameter </param>
/// <Param name = "LOGNAME"> log file name </param>
/// <Returns> </returns>
Public bool imporacledatabase (string username, string PWD, string dbserver, string pathname, string databasefilename, string appendcommand, string LOGNAME, string sqltextconfig)
{
This. sqltextfilename = sqltextconfig;
# Region/* xmlsql corner execution */
// Backup database information
Dbentity = new dbentity ();
Dbentity. dbserver = dbserver;
Dbentity. Username = username;
Dbentity. Pwd = PWD;
If (file. exists (sqltextfilename) & sqltextfilename! = String. Empty)
{
Exeuserspacesql (dbentity );
}
# Endregion
// Imp userid = system/zhice @ JC ignore = y rows = y indexes = N full = y file = D: \ demo. dmp log = D: \ demo. Log
String loginstring = string. Format ("userid = {0}/{1} @ {2}", username, PWD, dbserver );
String filename = "Imp ";
String arguments = string. format ("{0} full = y file = {1} log = {2}", loginstring, pathname + "\" + databasefilename, pathname + "\" + LOGNAME );
String backupcommand = string. Format ("{0} {1}", filename, arguments );
Try
{
System. Diagnostics. Process bakupprocess = new system. Diagnostics. Process ();
Bakupprocess. startinfo. filename = filename;
Bakupprocess. startinfo. Arguments = arguments;
Bakupprocess. Start ();
Return true;
}
Catch (exception ex)
{
System. Diagnostics. Debug. writeline (Ex );
Return false;
}
}

# Endregion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.