1

I want to take backup or restore of my oracle database through .Net code. I searched a lot but not found any correct solution. Like we do backup in SQL server by executing query.

backup database :DatabaseName to disk = ':DestinationPath

same I want to do in Oracle.

3
  • I'm pretty sure the Oracle manuals will be able to tell you what's the correct command for this. Commented May 24, 2012 at 12:58
  • 1
    You can use Oracle Data Pump: oracle-base.com/articles/10g/oracle-data-pump-10g.php. You may have to do it from a console script, as opposed to a database script in Oracle. Commented May 24, 2012 at 13:02
  • 2
    @mservidio: dataPump can be started through SQL as well. That's the big advantage over the (obsolete) exp/imp tools Commented May 24, 2012 at 13:31

4 Answers 4

5

You can use an Oracle utility like exp/imp or the newer Oracle Data Pump to create database exports (backups), though you have to execute these outside of the database, in a command line/terminal window. See this for more information: http://www.oracle-base.com/articles/10g/oracle-data-pump-10g.php

Update: I stand corrected. A Data Pump job can be started through PL/SQL. Thanks @a-horse-with-no-NAME.

This article shows how to start a Data Pump job from sql: http://docs.oracle.com/cd/B19306_01/server.102/b14215/dp_api.htm#i1006925

Sign up to request clarification or add additional context in comments.

3 Comments

You can start a data pump export through SQL using the dbms_datapump package: docs.oracle.com/cd/B28359_01/appdev.111/b28419/…
@a_horse_with_no_name - Just to be pedantic, you can start a DataPump export job through PL/SQL, not SQL, right (well, barring a function that uses autonomous transactions and is called from SQL).
@JustinCave: yes, good point. But usually an interface/driver that lets you run SQL will also let you run PL/SQL.
1

Careful: a DataPump or Exp Export is not a real Oracle Backup, and you should test to make sure you can restore from the Dump files you're creating. The closest thing Oracle has to SQL Server's BACKUP DATABASE command is RMAN, and even then it's quite different. But it is very useful to call from a Batch File. I'm both a DBA for SQL Server and Oracle, and the way each Engine performs Backups is one of the biggest differences. Exp and Imp are more similar to SQL's bcp commands (but more powerful). Exp won't backup your Controlfile or AchiveLogs, and you may need these in case of a disaster. With Exp, make sure you use CONSISTENT=Y option (FLASHBACK_TIME for newer DataPump Export). SQL Server backups are much more straight forward, and easier to recover.

Comments

0

I found an easy way to take backup of oracle database though code. I take credentials from user through code and make dynamically batch file of exp/imp commands. and run this batch command with process class.

Thank you all for your responses.

Comments

-3
OledbCommand cmd=new OledbCommand ("backup database databasename to disk ='C:\databasename.bak'",con);

con.open();

cmd.ExecutenonQuery();

con.close();

3 Comments

That's not the question. The backup database command is invalid for Oracle.
Thanks buddy.. I came to know... :)
The guy is asking help for Oracle.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.