1, modify the Rman configuration, can recover to 7 days of any point in time
Su-oracle
Rman Target/
Configure retention policy to recovery windows of 7 days;
Show All;
2. Create backup database and archive log Rman script Online_database_archivelog.rman
#创建备份目录
Mkdir-pv/backup/oraclebk/database
Mkdir-pv/backup/oraclebk/archivelog
Chown-r Oracle.oinstall
Su-oracle
mkdir scripts
CD scripts
Vim Online_database_archivelog.rman
#rman脚本内容
Run {
Allocate channel T1 type disk;
Allocate channel T2 type disk;
Backup as compressed backupset database format '/backup/oraclebk/database/database.%t.%u.rman ';
Backup as compressed backupset archivelog all Delete all input format '/backup/oraclebk/archivelog/archivelog.%t.%u.rman ‘;
}
Delete NoPrompt obsolete;
#delete noprompt obsolete; Delete an invalid or outdated backup set
3. Create a backup shell script
Su-oracle
mkdir scripts
CD scripts
Vim rman_backup.sh
#shell脚本内容
#!/bin/bash
SOURCE ~/.bash_profile
Rman target/@/home/oracle/scripts/online_database_archivelog.rman >/home/oracle/scripts/backup.log
4. Add Scheduled Tasks daily 04:00 backup
Su-oracle
Crontab-e
XX * sh/home/oracle/scripts/rman_backup.sh >/dev/null 2>&1
5. Perform incomplete recovery based on point in time (requires archive log and redo log complete, RAC environment needs to close another instance)
Run {
Shutdown immediate;
startup Mount;
Set until Time = "to_date (' 02-02-18 16:20:00 ', ' dd-mm-yy hh24:mi:ss ')";
Restore database;
Recover database;
ALTER DATABASE open resetlogs;
}
Oracle Rman Backup and restore scenario