I want to export the full Oracle database automatically each day. I know in order to export it, we use the commande bellow:
exp userid=user/pass full=yes file='expdat.dmp' log='file.log'
but i want to know how to do it automatically. And is there a way to do it with pl/sql?
[EDIT] I created a .bat file containing the command below. and i created dbms_scheduler job as following:
BEGIN
dbms_scheduler.create_credential(
credential_name => 'c',
username => 'user',
password => 'password');
SYS.DBMS_SCHEDULER.CREATE_JOB( job_name => 'ex_job_1',
job_type => 'EXECUTABLE',
job_action => 'C:\WINDOWS\system32\cmd.exe',
job_class => 'DEFAULT_JOB_CLASS',
comments => 'Job to call batch script on Windows',
auto_drop => FALSE,
number_of_arguments => 3,
enabled => FALSE,
credential_name=>'c'
);
SYS.DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE( job_name => 'ex_job_1', argument_position => 1, argument_value => '/q');
SYS.DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE( job_name => 'ex_job_1', argument_position => 2, argument_value => '/c');
SYS.DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE( job_name => 'ex_job_1', argument_position => 3, argument_value => '"C:\Backup_folder\export_database.bat"');
SYS.DBMS_SCHEDULER.ENABLE( 'ex_job_1' );
DBMS_SCHEDULER.RUN_JOB('ex_job_1');
END;
and it gives me the following errors:
Error Report -
ORA-06550: Line 2, column 17:
PLS-00302: The 'CREATE_CREDENTIAL' component must be declared
ORA-06550: Line 2, column 2:
PL / SQL: Statement ignored
ORA-06550: Line 7, column 5:
PLS-00306: number or wrong argument types in call to 'CREATE_JOB'
ORA-06550: Line 7, column 5:
PL / SQL: Statement ignored
06550. 00000 - "line% s, column% s: \ n% s"
* Cause: Usually a PL / SQL compilation error.
*Action:
I'm stuck, what should i do?
PS:A schema export might be enough for what i need.
RMANto take a full backup.