Article

Creating an oracle backup

1. Create the following files:

CheckForFileExists.sql

SET serveroutput ON
SET FEEDBACK OFF

begin
    IF  dbms_lob.FileExists(BFILENAME('&1','&2')) = 1 THEN
         DBMS_OUTPUT.PUT_LINE('Backup File Exists');      
    ELSE
          DBMS_OUTPUT.PUT_LINE('Backup File Does Not Exists');            
    END IF;
end;
/
exit;

CreateBackupDirectory.sql

set serveroutput on;
CREATE OR REPLACE DIRECTORY &1 AS '&3';
GRANT READ, WRITE ON DIRECTORY &1 to &2;
exit;

RecompileSchema.sql

DBMS_OUTPUT.ENABLE (buffer_size => NULL);
set serveroutput on;
DBMS_OUTPUT.PUT_LINE('Recompile schemas started: $2');
exec DBMS_UTILITY.compile_schema('&2');
commit;
DBMS_OUTPUT.PUT_LINE('Recompile schemas finished');
exit;

CreateBackup.cmd

set NLS_LANG=russian_cis.ru8pc866

rem %1 = Schema Name
rem %2 = Server Name
rem %3 = sqlplus.exe path
rem %4 = Backup directory alias
rem %5 = Exported dump name
rem %6 = Backup file directory(\\tscrm.com\dfs-ts\ReleaseBackups\For_7.10.2\)
rem %7 = Instance Port

%3 "SYSTEM/admin@%2:%7/orcle AS SYSDBA" @CreateBackupDirectory.sql %4 %1 %6
%3 "%1/%1@%2:%7/orcle" @RecompileSchema.sql "%1" "%1"
%3 -S "SYSTEM/admin@%2:%7/orcle" as sysdba @CheckForFileExists.sql %4 %5
expdp "%1/%1@//%2:%7/orcle" SCHEMAS=%1 DIRECTORY=%4 DUMPFILE=%5 NOLOGFILE=YES CONSISTENT=N VERSION=11.2.0.1.0 PARALLEL=2 COMPRESSION=ALL 

exit /b %ERRORLEVEL%

rem sqlplus BPMONLINE520BANKSOFTKEY/BPMONLINE520BANKSOFTKEY@TSCOREBUILD_ORA11 @NoAuditSession.sql
rem exp BPMONLINE520BANKSOFTKEY/BPMONLINE520BANKSOFTKEY@TSCOREBUILD_ORA11 triggers=y indexes=y grants=y rows=y constraints=y consistent=y statistics=none file='C:\TEST.dmp'

pause;

2. Locate the files in the same folder. In my case, it's e:\ORACLE\temp\

3. Open the CreateBackup.cmd and edit it according to the server connection properties in the Oracle SQL Developer client.

CreateBackupModification.png

4. Run "Command prompt" and enter the folder with the files. 

https://www.digitalcitizen.life/command-prompt-how-use-basic-commands

In my case, it looks like

command_dir.jpg

5. Adjust the command

CreateBackup.cmd SE_M_SE7140ENU localhost C:\app\Eugene\product\11.2.0\dbhome_1\BIN\sqlplus.exe BACKUPDIR SALESENTERPRISE_MARKETING_SERVICEENTERPRISEENUActual.DMP C:\OracleBackups 1521

where

SE_M_SE7140ENU - The name of the user (the database) that you want to backup. userName.jpg

localhost - the server IP.

C:\app\Eugene\product\11.2.0\dbhome_1\BIN\sqlplus.exe - the path to the sqlplus.exe file. 

SALESENTERPRISE_MARKETING_SERVICEENTERPRISEENUActual.DMP - the name of the backup that will be created. 

C:\OracleBackups - the location where the backup will be created. Please create the specified folder. It won't be created automatically. 

6. Run the command in the command prompt.

RunTheCommand.jpg

7. Find the backup in the specified folder. 

 

 

 

 

 

 

 

Like 0

Like

Share

0 comments
Show all comments