oracle备份计划
oracle备份计划
所有的脚本匀在/dsk3/bk/scripts中
①[oracle@sia scripts]$ cat connect.rcv (连接rman脚本) connect target sys/oracle@prod; ②[oracle@sia scripts]$ cat del_obso.rcv (删除归档日志状态为expired的日志和obsolete的文件) run{ CONFIGURE RETENTION POLICY TO REDUNDANCY 3; crosscheck archivelog all; delete noprompt expired archivelog all; delete noprompt obsolete; } ③[oracle@sia scripts]$ cat bkarch.rcv (备份归档日志) run{ sql 'alter system archive log current'; backup as compressed backupset format='/dsk3/backup/arch_%d_%U.bak' archivelog all delete input; } ④[oracle@sia scripts]$ cat bkctl.rcv (备份控制文件) run{ backup as compressed backupset current controlfile reuse format='/dsk3/backup/bkctl.bak'; } ⑤[oracle@sia scripts]$ cat inc0.rcv (0级差异增量备份) @@/dsk3/bk/scripts/connect.rcv @@/dsk3/bk/scripts/bkarch.rcv run{ allocate channel ch1 device type disk; allocate channel ch2 device type disk; set limit channel ch1 readrate=10240; set limit channel ch1 kbytes=4096000; set limit channel ch2 readrate=10240; set limit channel ch2 kbytes=4096000; backup as compressed backupset incremental level 0 database format='/dsk3/backup/inc0_%d_%U.bak'; release channel ch1; release channel ch2; } @@/dsk3/bk/scripts/del_obso.rcv @@/dsk3/bk/scripts/bkctl.rcv exit; ⑥[oracle@sia scripts]$ cat inc1.rcv (1级差异增量备份) @@/dsk3/bk/scripts/connect.rcv @@/dsk3/bk/scripts/bkarch.rcv run{ allocate channel ch1 device type disk; allocate channel ch2 device type disk; set limit channel ch1 readrate=10240; set limit channel ch1 kbytes=4096000; set limit channel ch2 readrate=10240; set limit channel ch2 kbytes=4096000; backup as compressed backupset incremental level 1 database format='/dsk3/backup/inc1_%d_%U.bak'; release channel ch1; release channel ch2; } @@/dsk3/bk/scripts/del_obso.rcv @@/dsk3/bk/scripts/bkctl.rcv exit; ⑦[oracle@sia scripts]$ cat inc1_c.rcv (1级累积增量备份) @@/dsk3/bk/scripts/connect.rcv @@/dsk3/bk/scripts/bkarch.rcv run{ allocate channel ch1 device type disk; allocate channel ch2 device type disk; set limit channel ch1 readrate=10240; set limit channel ch1 kbytes=4096000; set limit channel ch2 readrate=10240; set limit channel ch2 kbytes=4096000; backup as compressed backupset incremental level 1 cumulative database format='/dsk3/backup/inc1_c_%d_%U.bak'; release channel ch1; release channel ch2; } @@/dsk3/bk/scripts/del_obso.rcv @@/dsk3/bk/scripts/bkctl.rcv exit; ⑧[oracle@sia scripts]$ cat inc0.sh nohup $ORACLE_HOME/bin/rman cmdfile=/dsk3/bk/scripts/inc0.rcv log=/dsk3/bk/scripts/inc0.log append & [oracle@sia scripts]$ cat inc1.sh nohup $ORACLE_HOME/bin/rman cmdfile=/dsk3/bk/scripts/inc1.rcv log=/dsk3/bk/scripts/inc1.log append & [oracle@sia scripts]$ cat inc1_c.sh nohup $ORACLE_HOME/bin/rman cmdfile=/dsk3/bk/scripts/inc1_c.rcv log=/dsk3/bk/scripts/inc1_c.log append & ⑨[oracle@sia scripts]$ crontab -l 30 1 * * 0 /dsk3/bk/scripts/inc0.sh 30 1 * * 1 /dsk3/bk/scripts/inc1.sh 30 1 * * 2 /dsk3/bk/scripts/inc1.sh 30 1 * * 3 /dsk3/bk/scripts/inc1_c.sh 30 1 * * 4 /dsk3/bk/scripts/inc1.sh 30 1 * * 5 /dsk3/bk/scripts/inc1_c.sh 30 1 * * 6 /dsk3/bk/scripts/inc1.sh
-------------------------------华丽分割线--------------------------------
每小时备份,0 1 1 1 级别
[oracle@sia scripts]$ cat connect.rcv connect target sys/oracle@prod; [oracle@sia scripts]$ cat hourinc0.rcv @@/dsk3/bk/scripts/connect.rcv run{ backup as compressed backupset incremental level 0 database format='/dsk2/backup/inc0_%d_%U.bak'; } exit; [oracle@sia scripts]$ cat hourinc1.rcv @@/dsk3/bk/scripts/connect.rcv run{ backup as compressed backupset incremental level 1 database format='/dsk2/backup/inc1_%d_%U.bak'; } exit; [oracle@sia scripts]$ cat hourinc0.sh nohup $ORACLE_HOME/bin/rman cmdfile=/dsk3/bk/scripts/hourinc0.rcv log=/dsk3/bk/scripts/hourinc0.log append & [oracle@sia scripts]$ cat hourinc1.sh nohup $ORACLE_HOME/bin/rman cmdfile=/dsk3/bk/scripts/hourinc1.rcv log=/dsk3/bk/scripts/hourinc1.log append & [oracle@sia scripts]$ crontab -l * */1 * * * /dsk3/bk/scripts/hourinc0.sh */15 */1 * * * /dsk3/bk/scripts/hourinc1.sh */30 */1 * * * /dsk3/bk/scripts/hourinc1.sh */45 */1 * * * /dsk3/bk/scripts/hourinc1.sh