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

【Oracle Database】数据库完整备份与日志备份

时间:2020-11-26 15:19:56      阅读:23      评论:0      收藏:0      [点我收藏+]

标签:rip   script   cross   form   oracle   rman   arch   rom   oss   

[oracle@wallet01 ~]$ cat /home/oracle/script/full_backup.sh
#!/bin/bash
if [ -f ~/.bash_profile ];
then
  . ~/.bash_profile
fi
export SH_HOME=/home/oracle/script
rman target / @$SH_HOME/full_backup.sql

[oracle@wallet01 ~]$ cat /home/oracle/script/full_backup.sql
RUN {
BACKUP INCREMENTAL LEVEL=0 DATABASE
FORMAT ‘/home/oracle/backup/gstadb_full_backup_%s_%p_%T‘
PLUS ARCHIVELOG
FORMAT ‘/home/oracle/backup/gstadb_arch_backup_%s_%p_%T‘ delete all input;
DELETE NOPROMPT OBSOLETE;
CROSSCHECK BACKUP;
DELETE EXPIRED BACKUP;
}

[oracle@wallet01 ~]$ cat /home/oracle/script/arch_backup.sh
#!/bin/bash
if [ -f ~/.bash_profile ];
then
  . ~/.bash_profile
fi
export SH_HOME=/home/oracle/script
rman target / @$SH_HOME/arch_backup.sql

[oracle@wallet01 ~]$ cat /home/oracle/script/arch_backup.sql
RUN {
sql ‘alter system archive log current‘;
BACKUP ARCHIVELOG ALL FORMAT ‘/home/oracle/backup/gstadb_arch_backup_%s_%p_%T‘;
DELETE NOPROMPT OBSOLETE;
CROSSCHECK BACKUP;
DELETE EXPIRED BACKUP;
}

[oracle@wallet01 ~]$ cat /home/oracle/script/day_backup.sh
#!/bin/bash
mkdir -p /home/oracle/day_backup/`date ‘+%Y%m%d‘`
cp -p /home/oracle/backup/* /home/oracle/day_backup/`date ‘+%Y%m%d‘`
find /home/oracle/day_backup/ -type d -mtime +6 -exec rm -rf {} \;

[oracle@wallet01 ~]$ crontab -l
0 0 * * * /home/oracle/script/oracle_backup.sh
*/10 1-23 * * * /home/oracle/script/log_backup.sh
55 23 * * * /home/oracle/script/day_backup.sh

 

【Oracle Database】数据库完整备份与日志备份

标签:rip   script   cross   form   oracle   rman   arch   rom   oss   

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

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