oracle全量、增量备份

采用0221222增量备份策略,7天一个轮回

也就是周日0级备份,周1 2 4 5 6 采用2级增量备份,周3采用1级增量备份

打开控制文件自动备份

CONFIGURE CONTROLFILE AUTOBACKUP ON;

配置控制文件备份路径

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/file/backup/rman/controlfile_%F';

将过期天数设为7天

RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;

---全备

vim rman_bak_level0.sh

#! /bin/bash

export ORACLE_BASE=/u01/oracle

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1

export PATH=ORACLE_HOME/bin:PATH

export ORACLE_SID=neal --数据库ORACLE_SID

export NLS_LANG='AMERICAN_AMERICA.ZHS16GBK' --字符集

rman target / <<EOF run{ allocate channel d1 type disk; --分配通道d1,类型备份到磁盘

allocate channel d2 type disk; --分配通道d2,类型备份到磁盘

backup incremental level 0 database format '/file/backup/rman/level0_%d_%s_%p_%u.bkp'; --备份级别、输出格式、路径

sql 'alter system archive log current'; --对当前redo日志进行归档

backup archivelog all delete input format '/file/backup/rman/archivelog_%d_%s_%p_%u.bkp'; --备份归档日志并删除

crosscheck backup; --检查备份

delete noprompt obsolete; --静默删除过期备份

release channel d1; --释放通道d1

release channel d2; --释放通道d2 }

EOF

---0级备份脚本

vim rman_bak_level0.sh

#! /bin/bash

export ORACLE_BASE=/u01/oracle

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1

export PATH=ORACLE_HOME/bin:PATH

export ORACLE_SID=neal

export NLS_LANG='AMERICAN_AMERICA.ZHS16GBK'

rman target / <<EOF

run{ allocate channel d1 type disk;

allocate channel d2 type disk;

backup incremental level 0 database format '/file/backup/rman/level0_%d_%s_%p_%u.bkp';

sql 'alter system archive log current'; backup archivelog all delete input format '/file/backup/rman/archivelog_%d_%s_%p_%u.bkp';

crosscheck backup;

delete noprompt obsolete;

release channel d1;

release channel d2; }

EOF

--1级备份脚本

vim rman_bak_level1.sh

#! /bin/bash

export ORACLE_BASE=/u01/oracle

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1

export PATH=ORACLE_HOME/bin:PATH

export ORACLE_SID=neal

export NLS_LANG='AMERICAN_AMERICA.ZHS16GBK'

rman target / <<EOF

run{ allocate channel d1 type disk;

allocate channel d2 type disk;

backup incremental level 1 database format '/file/backup/rman/level1_%d_%s_%p_%u.bkp';

sql 'alter system archive log current'; backup archivelog all delete input format '/file/backup/rman/archivelog_%d_%s_%p_%u.bkp';

crosscheck backup;

delete noprompt obsolete;

release channel d1;

release channel d2; }

EOF

--2级备份脚本

vim rman_bak_level2.sh

#! /bin/bash export ORACLE_SID=neal

export NLS_LANG='AMERICAN_AMERICA.ZHS16GBK'

/u01/oracle/product/11.2.0/db_1/bin/rman target / <<EOF

run{ allocate channel d1 type disk;

allocate channel d2 type disk; backup incremental level 2 database format '/file/backup/rman/level2_%d_%s_%p_%u.bkp';

sql 'alter system archive log current';

backup archivelog all delete input format '/file/backup/rman/archivelog_%d_%s_%p_%u.bkp';

crosscheck backup;

delete noprompt obsolete;

release channel d1;

release channel d2; }

EOF

--加入到crontab中

crontab -e

#周日0级备份 00 23 * * 0 /server/scripts/rman_bak_level0.sh

#周一、二、四、五、六2级增量备份 00 23 * * 1,2,4,5,6 /server/scripts/rman_bak_level2.sh

#周三1级增量备份 00 23 * * 3 /server/scripts/rman_bak_level1.sh

日积月累

相关推荐
IT界的老黄牛7 分钟前
【IT老齐230 笔记 + 思考】金融业容灾方案“两地三中心“是什么意思?
数据库·笔记·架构
aiAIman7 分钟前
OpenClaw 用户必修课:(三)Claude Code 单一聊天原则、Hooks 与 LSP
数据库·人工智能·开源·aigc
oradh14 分钟前
Oracle单库环境下计划内启停数据库的步骤
数据库·oracle
DolphinDB智臾科技14 分钟前
2026 工业时序数据库选型指南:抽象复用能力如何降低 80% 开发成本——DolphinDB vs InfluxDB/TimescaleDB 深度对比与实践
数据库·物联网·时序数据库·dolphindb
xcLeigh17 分钟前
KWDB 跨界实战:当“时序数据库”遇上“草莓大棚”,数据如何指导种地?
数据库·物联网·智慧农业·时序数据库·农业·自动控制·kwdb
xuboyok219 分钟前
MySQL中ON DUPLICATE KEY UPDATE的介绍与使用、批量更新、存在即更新不存在则插入
android·数据库·mysql
倔强的石头10620 分钟前
MySQL 兼容性深度解析:从内核级优化到“零修改”迁移工程实践
数据库·mysql·adb·kingbase
V1ncent Chen21 分钟前
从零学SQL 03 Windows环境安装MySQL(图文版)
数据库·windows·sql·mysql·数据分析
todoitbo21 分钟前
时序数据库选型指南(实战版):少踩坑,能上线,跑得久
数据库·时序数据库·iotdb
高铭杰25 分钟前
Postgresql源码(154)Redo系列Storage Redo (RM_SMGR_ID = 2)
数据库·postgresql·smgr