码迷,mamicode.com
首页 > 数据库 > 详细

【Oracle Database】Oracle RMAN备份

时间:2020-11-21 12:03:07      阅读:9      评论:0      收藏:0      [点我收藏+]

标签:ram   ups   crontab   monk   sse   archive   serve   oba   orm   

[oracle@monkey01 ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Mar 26 13:48:45 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: MONKEY (DBID=1085070409)

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

RMAN> CONFIGURE BACKUP OPTIMIZATION ON;
new RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION ON;
new RMAN configuration parameters are successfully stored

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/home/oracle/backup/%F‘;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/home/oracle/backup/%F‘;
new RMAN configuration parameters are successfully stored

RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO COMPRESSED BACKUPSET;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO COMPRESSED BACKUPSET;
new RMAN configuration parameters are successfully stored

数据库完整备份
[oracle@monkey01 ~]$ mkdir backup
[oracle@monkey01 ~]$ vi full_backup.sql
RUN {
BACKUP INCREMENTAL LEVEL=0 TAG ‘soe_full_backup‘ DATABASE
FORMAT ‘/home/oracle/backup/soe_full_backup_%s_%p_%T‘
PLUS ARCHIVELOG
FORMAT ‘/home/oracle/backup/soe_arch_backup_%s_%p_%T‘ delete all input;
DELETE NOPROMPT OBSOLETE;
CROSSCHECK BACKUP;
DELETE EXPIRED BACKUP;
}

数据库增量备份
[oracle@monkey01 ~]$ vi incr_backup.sql
RUN {
BACKUP INCREMENTAL LEVEL=1 TAG ‘soe_incr_backup‘ DATABASE
FORMAT ‘/home/oracle/backup/soe_incr_backup_%s_%p_%T‘
PLUS ARCHIVELOG
FORMAT ‘/home/oracle/backup/soe_arch_backup_%s_%p_%T‘ delete all input;
DELETE NOPROMPT OBSOLETE;
CROSSCHECK BACKUP;
DELETE EXPIRED BACKUP;
}

[oracle@monkey01 ~]$ mkdir logs
[oracle@monkey01 ~]$ vi oracle_backup.sh
#!/bin/bash
if [ -f ~/.bash_profile ];
then
  . ~/.bash_profile
fi
export SH_HOME=/home/oracle
DATE=`date ‘+%Y%m%d%H‘`
WEEK=`date ‘+%A‘`
if [ "$WEEK" = "Sunday" ]
then
rman target / @$SH_HOME/full_backup.sql log=$SH_HOME/logs/full_backup_${DATE}.log
else
rman target / @$SH_HOME/incr_backup.sql log=$SH_HOME/logs/incr_backup_${DATE}.log
fi

[oracle@monkey01 ~]$ chmod a+x oracle_backup.sh

[oracle@monkey01 ~]$ crontab -e
0 3 * * * /home/oracle/oracle_backup.sh

[oracle@monkey01 ~]$ crontab -l
0 3 * * * /home/oracle/oracle_backup.sh

[oracle@monkey01 ~]$ cd backup
[oracle@monkey01 backup]$ ls -ltrh
total 645M
-rw-r----- 1 oracle oinstall  73M Mar 25 03:00 soe_full_backup_25_1_20180325
-rw-r----- 1 oracle oinstall 207M Mar 25 03:01 soe_full_backup_24_1_20180325
-rw-r----- 1 oracle oinstall 351M Mar 25 03:01 soe_full_backup_23_1_20180325
-rw-r----- 1 oracle oinstall 4.0K Mar 25 03:01 soe_arch_backup_26_1_20180325
-rw-r----- 1 oracle oinstall 596K Mar 26 03:00 soe_arch_backup_28_1_20180326
-rw-r----- 1 oracle oinstall 3.5K Mar 26 03:00 soe_arch_backup_32_1_20180326
-rw-r----- 1 oracle oinstall  48K Mar 26 03:00 soe_incr_backup_31_1_20180326
-rw-r----- 1 oracle oinstall  48K Mar 26 03:00 soe_incr_backup_35_1_20180326
-rw-r----- 1 oracle oinstall 392K Mar 26 03:00 soe_incr_backup_34_1_20180326
-rw-r----- 1 oracle oinstall 392K Mar 26 03:00 soe_incr_backup_30_1_20180326
-rw-r----- 1 oracle oinstall 1.9M Mar 26 03:01 soe_incr_backup_29_1_20180326
-rw-r----- 1 oracle oinstall 1.9M Mar 26 03:01 soe_incr_backup_33_1_20180326
-rw-r----- 1 oracle oinstall  10K Mar 26 03:01 soe_arch_backup_36_1_20180326
-rw-r----- 1 oracle oinstall  10K Mar 26 03:01 soe_arch_backup_37_1_20180326
-rw-r----- 1 oracle oinstall 9.4M Mar 26 03:01 c-1072562510-20180326-01

[oracle@monkey01 ~]$ cd logs
[oracle@monkey01 logs]$ ls -ltrh
total 20K
-rw-r--r-- 1 oracle oinstall 8.8K Mar 25 03:01 full_backup_2018032503.log
-rw-r--r-- 1 oracle oinstall 7.5K Mar 26 03:01 incr_backup_2018032603.log

 

【Oracle Database】Oracle RMAN备份

标签:ram   ups   crontab   monk   sse   archive   serve   oba   orm   

原文地址:https://www.cnblogs.com/dbamonkey/p/13992884.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!