首頁 資料庫 mysql教程 【rman,1】经典的增量备份案例

【rman,1】经典的增量备份案例

Jun 07, 2016 pm 04:01 PM
備份 晚上 案例 策略 經典

一.备份策略: 1.星期天晚上 -level 0 backup performed(全备份) 2.星期一晚上 -level 2 backup performed 3.星期二晚上 -level 2 backup performed 4.星期三晚上 -level 1 backup performed 5.星期四晚上 -level 2 backup performed 6.星期五晚上 -level 2 b

一.备份策略:

1.星期天晚上 -level 0 backup performed(全备份) 2.星期一晚上 -level 2 backup performed 3.星期二晚上 -level 2 backup performed 4.星期三晚上 -level 1 backup performed 5.星期四晚上 -level 2 backup performed 6.星期五晚上 -level 2 backup performed 7.星期六晚上 -level 2 backup performed 如果星期二需要恢复的话,只需要1+2, 如果星期四需要恢复的话,只需要1+4, 如果星期五需要恢复的话,只需要1+4+5, 如果星期六需要恢复的话,只需要1+4+5+6. 自动备份:备份脚本+crontab bakl0 bakl1 bakl2

二.执行的脚本:

1.执行脚本:

rman target / msglog=bakl0.log cmdfile=bakl0 (/表示需要连接的目标数据库,msglog表示日志文件,cmdfile表示的是脚本文件) rman target / msglog=bakl1.log cmdfile=bakl1 rman target / msglog=bakl2.log cmdfile=bakl2 实例:rman target system/oracle@ora10g(/) msglog=/u01/rmanbak/bakl1.log cmdfile=/u01/rmanbak/bakl0
完整的命令:/u01/oracle/product/10.2.0/bin/rman target system/oracle@ora10g(/) msglog=/u01/rmanbak/bakl1.log cmdfile=/u01/rmanbak/bakl0

2.编写rman备份脚本: 0级备份脚本:

把备份脚本放到/u01/rmanbak/script目录下面,vi bakl0,bakl0的内容为: run{ allocate channel cha1 type disk; backup incremental level 0 format '/home/oracle/rmanbackup/inc0_%u_%T'(u表示唯一的ID,大T是日期,小t是时间) tag monday_inc0 //标签可以顺便起,没关系 database plus archivelog delete input; release channel cha1; } 1级备份脚本: run{ allocate channel cha1 type disk; backup incremental level 1 format '/home/oracle/rmanbackup/inc1_%u_%T'(u表示唯一的ID,大T是日期,小t是时间) tag monday_inc1 //标签可以顺便起,没关系 database plus archivelog delete input; release channel cha1; }
2级备份脚本: run{ allocate channel cha1 type disk; backup incremental level 2 format '/home/oracle/rmanbackup/inc2_%u_%T'(u表示唯一的ID,大T是日期,小t是时间) tag monday_inc2 //标签可以顺便起,没关系 database plus archivelog delete input; release channel cha1; }

3.编写调用rman脚本的shell脚本:

调用0备份的shell脚本 rmanbak0.sh为: #!/bin/bash source /home/oracle/.bash_profile /u01/app/oracle/11.2.0/db_home_1/bin/rman target / nocatalog cmdfile=/home/oracle/script/bakl0 msglog=/home/oracle/bakl0.log
调用1备份的shell脚本 rmanbak0.sh为: #!/bin/bash source /home/oracle/.bash_profile /u01/app/oracle/11.2.0/db_home_1/bin/rman target / nocatalog cmdfile=/home/oracle/script/bakl1 msglog=/home/oracle/bakl0.log 调用2备份的shell脚本 rmanbak0.sh为: #!/bin/bash source /home/oracle/.bash_profile /u01/app/oracle/11.2.0/db_home_1/bin/rman target / nocatalog cmdfile=/home/oracle/script/bakl2 msglog=/home/oracle/bakl0.log

4.编写Linux定时任务执行自动备份

[root@gc2 ~]#crontab -e -u oracle(该命令的意思是编辑oracle用户的定时执行(-e,edit -u oracle,oracle用户)) 分 时 日 月 星期(0代表星期天) 45 23 * * 0 /home/oracle/script/rmanbak0.sh(星期天的23:45会以oracle用户的身份来执行命令) 45 23 * * 1 /home/oracle/script/rmanbak2.sh 45 23 * * 2 /home/oracle/script/rmanbak2.sh 45 23 * * 3 /home/oracle/script/rmanbak1.sh 45 23 * * 4 /home/oracle/script/rmanbak2.sh 45 23 * * 5 /home/oracle/script/rmanbak2.sh45 23 * * 6 /home/oracle/script/rmanbak2.sh

或者(用于测试): 使用oracle用户添加例行任务: crontab -e 新打开的窗口中添加一下内容: 0 24 * * * /home/oracle/bin/rmanbak0.sh (*/3 * * * * /home/oracle/bin/rmanbak0.sh) 注,括号内的可以是做测试的时候用的,每三分钟执行一次备份,例为每天凌晨24点执行备份
#然后启动crontab ,启动crontab的命令: [root@gc2 ~]# service crond restart Stopping crond: [ OK ] Starting crond: [ OK ] #监控定时任务是否执行 [root@gc2 ~]# tail -f /var/log/cron
Mar 10 21:28:04 gc2 crond[4435]: (CRON) STARTUP (V5.0) Mar 10 21:30:01 gc2 crond[4445]: (root) CMD (/usr/lib/sa/sa1 1 1) Mar 10 21:39:08 gc2 crond[4486]: (CRON) STARTUP (V5.0)

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
2 週前 By 尊渡假赌尊渡假赌尊渡假赌
倉庫:如何復興隊友
4 週前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
2 週前 By 尊渡假赌尊渡假赌尊渡假赌
倉庫:如何復興隊友
4 週前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱門文章標籤

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

如何備份谷歌瀏覽器的擴充程序 如何備份谷歌瀏覽器的擴充程序 Jan 30, 2024 pm 12:36 PM

如何備份谷歌瀏覽器的擴充程序

如何在Windows 11的檔案總管中刪除啟動備份 如何在Windows 11的檔案總管中刪除啟動備份 Feb 18, 2024 pm 05:40 PM

如何在Windows 11的檔案總管中刪除啟動備份

hosts檔案刪了怎麼恢復 hosts檔案刪了怎麼恢復 Feb 22, 2024 pm 10:48 PM

hosts檔案刪了怎麼恢復

如何在 PHP 中使用 MySQL 備份和還原? 如何在 PHP 中使用 MySQL 備份和還原? Jun 03, 2024 pm 12:19 PM

如何在 PHP 中使用 MySQL 備份和還原?

ghost怎麼備份系統-ghost備份教學 ghost怎麼備份系統-ghost備份教學 Mar 06, 2024 pm 04:30 PM

ghost怎麼備份系統-ghost備份教學

如何安裝、解除安裝、重設Windows伺服器備份 如何安裝、解除安裝、重設Windows伺服器備份 Mar 06, 2024 am 10:37 AM

如何安裝、解除安裝、重設Windows伺服器備份

PHP秒殺系統中的價格策略與促銷活動設計要點 PHP秒殺系統中的價格策略與促銷活動設計要點 Sep 19, 2023 pm 02:18 PM

PHP秒殺系統中的價格策略與促銷活動設計要點

exe轉php:實作功能擴充的有效策略 exe轉php:實作功能擴充的有效策略 Mar 04, 2024 pm 09:36 PM

exe轉php:實作功能擴充的有效策略

See all articles