Simple cold backup synchronization for Oracle databases in Linux and other Windows systems
We have a financial system that focuses on the security of financial data. At the same time, we have two systems: a production environment (Linux) and an emergency backup environment (Windows ). The backup Environment implements real-time backup and synchronization for the production environment. There are also two backup methods: Hot Backup and cold backup. Oracle Hot Standby usually uses the Oracle DG service, but the Oracle DG service is charged separately, which is a small expense for the customer. So we adopt the Oracle cold backup method. The basic process is: the database is exported in expdp mode at regular intervals, and then transmitted to the emergency backup environment through ftp. The emergency backup environment is then imported using impdp, in this way, cold backup can be completed.
I. Linux Oracle database:
1. Add crontab timing time
2. Write shell scripts to export Databases
#! /Bin/bash
Yy = 'date + % y'
Mm = 'date + % m'
Dd = 'date + % d'
Time = $ yy $ mm $ dd
ORACLE_BASE =/oracle/app/oracle;
Export ORACLE_BASE;
ORACLE_HOME = $ ORACLE_BASE/product/11.2;
Export ORACLE_HOME;
PATH = $ ORACLE_HOME/bin: $ PATH;
Export PATH;
F_dmp = "FDB _ $ {time}. DMP"
F_log = "_ F $ {time}. LOG"
Echo "expdp ods/ods @ dw1 directory = backup_db dumpfile = $ f_dmp logfile = $1 $ f_log SCHEMAS = meta, ods, mid, app reuse_dumpfiles = y ;"
Echo "exporting data ..."
Expdp ods/ods @ dw1 directory = backup_db dumpfile = $ f_dmp logfile = $1 $ f_log SCHEMAS = meta, ods, mid, app reuse_dumpfiles = y;
Echo "expdp user data success! "
Ii. use ftp to transmit dmp files in the emergency backup environment. Of course, the production environment linux must support ftp
@ Echo off
SET P_YEAR = % date :~ 0, 4%
SET P_MONTH = % date :~ 5, 2%
SET P_DAY = % date :~ 8, 2%
SET P_DATE = % P_YEAR % P_MONTH % P_DAY %
Echo oracle> autoftp.txt
Echo oracle> autoftp.txt
Echo prompt> autoftp.txt
Echo bin> autoftp.txt
Echo get/home/oracle/FDB _ % P_DATE %. dmp d: \ data_backup \ db \ DB _ % P_DATE %. DMP> autoftp.txt
Echo get/home/oracle/_ F % P_DATE %. log d: \ data_backup \ db \ _ F % P_DATE %. log> autoftp.txt
Echo mdel/home/oracle/*. DMP> autoftp.txt
Echo mdel/home/oracle/_ F *. LOG> autoftp.txt
Echo bye> autoftp.txt
Ftp-s: "autoftp.txt" 127.0.0.1 (IP address)
Exit
Ftp generally uses the ftp-s ftp.txt operator to execute the ftpoperation, and generate the corresponding ftp.txt text in the previous step.
Oracle
Oracle
Prompt
Bin
Get/home/oracle/FDB_20140729.DMP D: \ data_backup \ db \ DB_20140729.DMP
Get/home/oracle/_ F20140729.LOG D: \ data_backup \ db \ _ F20140729.log
Mdel/home/oracle/*. DMP
Mdel/home/oracle/_ F *. LOG
Bye
Get/home/oracle/*. dmp C: \ 20141119.DMP
3. Since the dmp file is transmitted to the Windows system, you can use impdp For the import operation. Of course, the import operation should also be started using the Windows scheduled service.
@ Echo off
REM
REM
SET P_YEAR = % date :~ 0, 4%
SET P_MONTH = % date :~ 5, 2%
SET P_DAY = % date :~ 8, 2%
SET P_DATE = % P_YEAR % P_MONTH % P_DAY %
Impdp ods/ods @ dw directory = backup_db dumpfile = DB _ % P_DATE %. dmp SCHEMAS = meta, ods, mid, app table_exists_action = REPLACE
Pause
This method has several obvious disadvantages:
1. Export exp and import may affect the database performance.
2. databases cannot be synchronized in real time, which is not applicable to high data synchronization requirements and high data security.
3. Export transmission and import. The time must be staggered. This time point is difficult to control.
Oracle Database cold backup and full recovery