Use RMAN backup compression technology to fully backup the database and delete the backed up archive log after backing up the control file and archive log:
1. Make sure to open the archive
Check whether the database is open for archiving:
archive log list;
Close the database first
shutdown immediate;
Start the database to mount state, mount load control file
startup mount;
Open archive
alter database archivelog
******show all command can display the configured parameters with default values, including channel parameters
RMAN>show all;
Backup table space separately
Back up the USERS tablespace
RMAN>backup tablespace users;
Backup multiple tablespaces
RMAN>backup filesperset=3 tablespace users,system,sysaux;
backup as compressed backupset full database format '/home/oracle/backup/full_bk1_%u%p%s.dfb'
include current controlfile
plus archivelog format '/home/oracle/backup/arch_bk1_%u%p%s.dfb'
delete all input;
Perform entire database backup
RMAN> BACKUP DATABASE FORMAT '/u01/backup/FUL_BAK_%T';
--数据文件被备份到的路径和备份的数据文件有哪些
RMAN> LIST BACKUP OF DATABASE;
--参数文件和控制文件被备份到默认路径。
RMAN> LIST BACKUP OF SPFILE;
--备份归档日志文件
RMAN> BACKUP ARCHIVELOG ALL FORMAT '/u01/backup/ARC_%T';
--之前自己手动用rm命令删掉了归档日志。但是controlfile中还记录着归档日志信息,oracle还会去找这些归档日志文件,因此就会报错。
解决方法:使控制文件中的归档日志信息和实际物理文件信息保持一致;
1. corsscheck archivelog all;
此命令用来检查控制文件和实际物理文件信息的差异。
2.delete expired archivelog all;
删除无效的归档日志信息,使检查控制文件和实际物理文件信息同步。
--查看上一步备份的归档日志文件,可以查看归档scn是否连续完整
RMAN> LIST BACKUP OF ARCHIVELOG ALL;
Several backup methods of control file in RMAN
Reference blog: http://blog.itpub.net/31444259/viewspace-2154367/
-- 开启控制文件自动备份
--设置控制文件备份路劲和备份格式,加数据文件备份
run{
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to '/u01/backup01/%F';
BACKUP DATABASE FORMAT '/u01/backup01/FUL_BAK_%T';
}
Full documentation
--数据文件和控制文件
--归档文件
--spfile文件
run{
backup as compressed backupset full database FORMAT '/u01/backup01/full_bk1_%u%p%s.bak'
include current controlfile;
BACKUP ARCHIVELOG ALL FORMAT '/u01/backup01/ARC_%u%p%s';
backup spfile format '/u01/backup01/SPFILE_%d';
}
--和以上的区别是,控制文件是单独备份的
run{
backup as compressed backupset full database FORMAT '/u01/backup01/full_bk1_%u%p%s.bak';
backup current controlfile format '/u01/backup01/Con_%u%p%s.bak';
BACKUP ARCHIVELOG ALL FORMAT '/u01/backup01/ARC_%u%p%s';
backup spfile format '/u01/backup01/SPFILE_%d';
}
Control file backup
Specify backup compression
Add as compressed backupset after backup
method one:
backup current controlfile format '/u01/backup01/c_bk1_%u%p%s.bak';
Method Two:
--执行 BACKUP 时指定 INCLUDE CURRENT CONTROLFILE 参数,例如:
RMAN> BACKUP DATABASE INCLUDE CURRENT CONTROLFILE;
如果要查看备份的控制文件,可以通过:
RMAN> LIST BACKUP OF CONTROLFILE;
OMF method to compress and backup the entire library (data file + control file)
backup as compressed backupset database to destination '/u01/backup01/';
--不压缩备份
backup database to destination '/u01/backup01/';
Check the validity of the backup set
Verify backup set
RMAN> crosscheck backupset;
or
RMAN> crosscheck backup;
Delete invalid backup set
RMAN> delete obsolete;
Verify the validity of archive logs
RMAN> crosscheck archivelog all;
Invalid archive, can be deleted
Effective filing
List all failed archive logs
list expired archivelog all;
Delete all archive logs with log sequence 16 and before 16
delete archivelog until sequence 16;
--Delete the archive logs 7 days before the system time, and will not delete the archive logs valid in the flashback area
delete archivelog all completed before 'sysdate-7';
-This command clears all archive logs
delete noprompt archivelog all;
Knowledge replenishment:
Detailed explanation of RMAN commands
https://www.iteye.com/blog/wallimn-1208204