A friend asked me to back up the database with exp at every night to the specified directory and automatically delete the data backed up one week ago.
A friend asked me to back up the database with exp at every night to the specified directory and automatically delete the data backed up one week ago.
A friend asked me to back up the database with exp at every night to a specified directory and automatically delete the data backed up one week ago, record and share the process only.
For the case of Oracle automatic backup on Linux (using RMAN), see
Environment:
Operating System: RHEL5.4
Database: Oracle 10.2.0
Related variable values:
ORACLE_BASE =/u01/app/oracle
ORACLE_HOME =/u01/app/oracle/product/10.2.0/db_1
Backup solution name: MAI
Target backup Directory:/backup
The implementation process is as follows:
Prepare the directory:
Mkdir/backup
Chown oracle: oinstall/backup
Chmod 755/backup
Switch to the oracle user, create the bin directory under the oracle Home directory, and create the on_time_backup.sh file.
Mkdir bin
Cd bin
Touch on_time_backup.sh
Chmod 755 on_time_backup.sh
Edit the on_time_backup.sh file and add the following content:
#! /Bin/bash
Source/home/oracle/. bash_profile
/U01/app/oracle/product/10.2.0/db_1/bin/exp userid = mai/mai file =/backup/BACKUP_SCHEMA_MAI _ 'date + % Y % m % d % H % M '. dmp log =/backup/BACKUP_SCHEMA_MAI _ 'date + % Y % m % d % H % M '. log
/Usr/bin/find/backup-mtime + 7-exec rm-rf {}\;
Use oracle users to add routine tasks:
Crontab-e
Add the following content to the new window:
0 24 ***/home/oracle/bin/on_time_backup.sh
(*/1 *****/home/oracle/bin/on_time_backup.sh)
Note: The brackets can be used for testing. A backup is performed every minute.
You can check whether the script is executed by monitoring the/var/log/cron file. If the script is executed, check whether the corresponding backup file exists under the/backup directory:
-Rw-r -- 1 oracle oinstall 16384 Jul 5 BACKUP_SCHEMA_MAI_201207051333.dmp
-Rw-r -- 1 oracle oinstall 1800 Jul 5 BACKUP_SCHEMA_MAI_201207051333.log
-Rw-r -- 1 oracle oinstall 16384 Jul 5 BACKUP_SCHEMA_MAI_201207051335.dmp
-Rw-r -- 1 oracle oinstall 1800 Jul 5 BACKUP_SCHEMA_MAI_201207051335.log
-Rw-r -- 1 oracle oinstall 16384 Jul 5 BACKUP_SCHEMA_MAI_201207051336.dmp
-Rw-r -- 1 oracle oinstall 1800 Jul 5 BACKUP_SCHEMA_MAI_201207051336.log
-Rw-r -- 1 oracle oinstall 16384 Jul 5 BACKUP_SCHEMA_MAI_201207051337.dmp
-Rw-r -- 1 oracle oinstall 1800 Jul 5 BACKUP_SCHEMA_MAI_201207051337.log
-Rw-r -- 1 oracle oinstall 16384 Jul 5 BACKUP_SCHEMA_MAI_201207051338.dmp
-Rw-r -- 1 oracle oinstall 1800 Jul 5 BACKUP_SCHEMA_MAI_201207051338.log
Recommended reading:
Basic Oracle tutorial-copying a database through RMAN
Reference for RMAN backup policy formulation
RMAN backup learning notes
Oracle Database Backup encryption RMAN Encryption