backup script
#!/bin/bash
#####################################################
# export the whole database use exp utility. #
##################################################### #########load db profile#############################
. ~/profile/c21upg10.profile #########set nls_lang################################
db_nls_value=`sqlplus -s / as sysdba <<EOF
select userenv('language') from dual;
EXIT
EOF`
NLS_LANG=`(echo $db_nls_value | cut -d' ' -f3)`
export NLS_LANG ##########exp########################################
file_name="${ORACLE_SID}_full_`date '+%y%m%d'`.dmp"
log_name="${ORACLE_SID}_imp_`date '+%y%m%d'`.log"
backup_location=/u01/db_backup
exp \'/ as sysdba\' file=$backup_location/$ORACLE_SID/$file_name log=$backup_location/$ORACLE_SID/$log_name full=y ##########compress and delete obsoleteness###########
gzip $backup_location/$ORACLE_SID/*.dmp
后来加了一段删除冗余代码。 这段代码中要记住的有几点
1. 设置日期
date -d "-1 week" +%y%m%d
date -d "-1 day" +%y%m%d
2. 判断shell命令执行成功与否
command ; flag=$?
if [ $flag -eq 0 ]
cur_bak=$backup_location/$ORACLE_SID/${ORACLE_SID}_full_`date '+%y%m%d'`.dmp.gz
cur_bak_7=$backup_location/$ORACLE_SID/${ORACLE_SID}_full_`date -d "-1 week" +%y%m%d`.dmp.gz
cur_bak_14=$backup_location/$ORACLE_SID/${ORACLE_SID}_full_`date -d "-2 week" +%y%m%d`.dmp.gz
cur_log=$backup_location/$ORACLE_SID/${ORACLE_SID}_imp_`date '+%y%m%d'`.log
cur_log_7=$backup_location/$ORACLE_SID/${ORACLE_SID}_imp_`date -d "-1 week" +%y%m%d`.log
cur_log_14=$backup_location/$ORACLE_SID/${ORACLE_SID}_imp_`date -d "-4 week" +%y%m%d`.log
if [ -a $cur_bak ] && [ -a $cur_bak_7 ] && [ -a $cur_bak_14 ] ;
then
grep "Export terminated successfully without warnings" $cur_log >/dev/null >& ; flag1=$?
grep "Export terminated successfully without warnings" $cur_log_7 >/dev/null >& ; flag2=$?
grep "Export terminated successfully without warnings" $cur_log_14>/dev/null >& ; flag3=$?
if [ $flag1 -eq ] && [ $flag2 -eq ] && [ $flag3 -eq ] ;
then
mkdir $backup_location/$ORACLE_SID/temp; flag1=$?
mv $cur_bak $backup_location/$ORACLE_SID/temp ;flag2=$?
mv $cur_bak_7 $backup_location/$ORACLE_SID/temp ;flag3=$?
mv $cur_bak_14 $backup_location/$ORACLE_SID/temp ;flag4=$?
mv $cur_log $backup_location/$ORACLE_SID/temp ;flag5=$?
mv $cur_log_7 $backup_location/$ORACLE_SID/temp ;flag6=$?
mv $cur_log_14 $backup_location/$ORACLE_SID/temp ;flag7=$?
if [ $flag1 -eq ] && [ $flag2 -eq ] && [ $flag3 -eq ] && [ $flag4 -eq ] && [ $flag5 -eq ] && [ $flag6 -eq ] && [ $flag7 -eq ] ;
then
rm $backup_location/$ORACLE_SID/*.gz ; flag1=$?
rm $backup_location/$ORACLE_SID/*.log; flag2=$?
mv $backup_location/$ORACLE_SID/temp/* $backup_location/$ORACLE_SID/; flag3=$?
rm -r $backup_location/$ORACLE_SID/temp/; flag4=$?
if [ $flag1 -eq 1 ] || [ $flag2 -eq 0 ] || [ $flag3 -eq 0 ] || [ $flag4 -eq 0 ];then
echo "send email for here0"
fi
fi
fi
else
echo "send email for here1"
fi
backup script的更多相关文章
- A Mysql backup script
UseCentOS can help IT managers to get rid of the boring learning methods, quick grasp Linux technolo ...
- 1950261 - SAP HANA Database Backup Policy Recommendations and Regular Backup Script
=====Symptom For SAP Business One, version for SAP HANA users, SAP HANA provides a range of database ...
- SharePoint 2013 How to Backup Site Collection Automatically With a PowerShell Script
In this post I will introduce a way how to run a script for backing up SharePoint data which could b ...
- Odoo Auto Backup Database And Set Linux task schedualer
First ,Write Database Backup Script: pg_dump -Fc yourdatabasename > /home/yourfilepath/yourdataba ...
- Python mysql backup
http://www.linuxidc.com/Linux/2015-02/113057.htm ------------- #!/usr/bin/python#################### ...
- 一键备份脚本 backup.sh
做网站最重要的是什么?数据!数据,是网站之本,备份,是每一个站长都应该重视的事情.但同时,备份也是一件繁琐和重复的事情.所以,这些事情,肯定能做到自动化的.下面来介绍一下这个一键备份脚本 backup ...
- postgresql backup
#!/bin/sh # Database backup script # Backup use postgres pg_dump command: # pg_dump -U <user> ...
- MySQL备份还原——AutoMySQLBackup介绍
AutoMySQLBackup是一个开源的MySQL备份脚本.可以说它是一个轻量级的备份方案,AutoMySQLBackup的安装.配置非常简单.方便.AutoMySQLBackup的sourcefo ...
- MySQL高可用架构之MHA
简介: MHA(Master High Availability)目前在MySQL高可用方面是一个相对成熟的解决方案,它由日本DeNA公司youshimaton(现就职于Facebook公司)开发,是 ...
随机推荐
- 题解报告:hdu 1028 Ignatius and the Princess III(母函数or计数DP)
Problem Description "Well, it seems the first problem is too easy. I will let you know how fool ...
- EF 新增数据时提示it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element
it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionM ...
- eclipse 安装svn插件记录
每个人都有自己喜欢的和习惯的一套开发环境,其中对于喜欢用eclipse的同学来说.subclipse插件可以说是必不可少的插件了. 他的安装有两种方法,一种是在线安装.然而这种安装实在是太慢了,无法忍 ...
- Android 自己搭建一个直播系统吧
服务端用 SRS(Simple Rtmp Server),在这里下载simple-rtmp-server需要Linux系统最好是Ubuntu,装个Ubuntu虚拟机就行了在Linux里,解压缩SRS ...
- JavaScript的相关知识
Oject.assign() // Cloning an object var obj = { a: 1 }; var copy = Object.assign({}, obj); conso ...
- css3背景渐变色代码
从上到下 #grad { background: -webkit-linear-gradient(red, blue); background: -o-linear-gradient(red, b ...
- 移动web——touch事件介绍
基本概念 1.在移动web端点击事件或者滑动屏幕.捏合等动作都是由touchstar.touchmove.touchend这三个事件组合在一起使用的 2.click事件在移动端会有0.2秒的延迟,下面 ...
- html——特殊字符
- 【译】x86程序员手册03 - 2.1内存组织和分段
2.1 Memory Organization and Segmentation 内存组织和分段 The physical memory of an 80386 system is organized ...
- WPF中的两个绑定场景
1. 如何在诸如ListBox这样的项中绑定父类数据上下文. <ListBox Grid.Row=" ItemsSource="{Binding Entries}" ...