现在的位置: 首页 > 综合 > 正文

给某机器cq设置的备份脚本

2014年11月09日 ⁄ 综合 ⁄ 共 1794字 ⁄ 字号 评论关闭

1crontab .txt:

root@GF # crontab -l

0 21 * * 0,2,4 /oracle/bakupscript/orafullbk.sh 1>>/tmp/orabak.log 2>&1
0 21 * * 1,3,5 /oracle/bakupscript/oraincrbk.sh 1>>/tmp/orabak.log 2>&1

orafullbk.sh:

#!/usr/bin/ksh

#
# Backup Oracle instanc
#
LANG=en_US
export LANG

echo Backup Oracle instance cq on `date`
su - oracle -c "/oracle/bakupscript/fullbkcq.sh"

 

 

oraincrbk.sh:

 

#!/usr/bin/ksh

#
# Backup Oracle instance
#
LANG=en_US
export LANG

echo Backup Oracle instance cq on `date`
su - oracle -c "/oracle/bakupscript/incrbkcq.sh"

 

 

fullbkcq.sh:

#!/usr/bin/ksh
#
# Backup database instance cq at incremental level 0 (full)
#
ORACLE_SID=CQ
export ORACLE_SID
rman target / catalog rman/rman@rman << EOF_RMAN
run {
 Allocate channel c1 device type disk; 
 Allocate channel c2 device type disk;
 BACKUP
    INCREMENTAL LEVEL 0
    FILESPERSET 10
    FORMAT '/oradata2/rman_backup/cq/full_%T_%s_%p'
    DATABASE;
 
  BACKUP
    FILESPERSET 10
    MAXSETSIZE 10G
    FORMAT '/oradata2/rman_backup/cq/arch_%Y%M%D_%s_%p'
    SKIP INACCESSIBLE
    ARCHIVELOG ALL DELETE INPUT;
   
  release channel c1;
  release channel c2;
}

EOF_RMAN

rman target / catalog rman/rman@rman << EOF_RMAN
  allocate channel for maintenance device type disk;
   delete noprompt obsolete recovery window of 10 days;
  release channel;
EOF_RMAN

incrbkcq.sh:

#!/usr/bin/ksh
#
# Backup database instance CQ at incremental level 1
#
ORACLE_SID=CQ
export ORACLE_SID
rman target / catalog rman/rman@rman << EOF_RMAN
run {
  Allocate channel c1 device type disk; 
 Allocate channel c2 device type disk;
  BACKUP
    INCREMENTAL LEVEL 1 CUMULATIVE
    FILESPERSET 10
    FORMAT '/oradata2/rman_backup/cq/incr_%T_%s_%p'
    DATABASE;
 
  BACKUP
    FILESPERSET 10
    MAXSETSIZE 10G
    FORMAT '/data2/rman_backup/cq/arch_%T_%s_%p'
    SKIP INACCESSIBLE
    ARCHIVELOG ALL DELETE INPUT;
  release channel c1;
  release channel c2;
}
EOF_RMAN

rman target / catalog rman/rman@rman << EOF_RMAN
  allocate channel for maintenance device type disk;
   delete noprompt obsolete recovery window of 10 days;
  release channel;
EOF_RMAN

 

抱歉!评论已关闭.