---
title: "判断导出是否成功"
author: "foolraty"
date: "2010-09-16T10:00:40Z"
tags: []
categories: ["数据库"]
slug: "untitled"
draft: false
lastmod: "2010-09-16T10:00:40Z"
id: 764567
url: "https://foolraty.iteye.com/blog/764567"
---

export ORACLE\_BASE=/u/oracle/

 

export ORACLE\_HOME=$ORACLE\_BASE/product/10.2.0/db\_2

 

export ORACLE\_SID=orcl

 

export PATH=$PATH:$HOME/bin:$ORACLE\_HOME/bin

 

export LD\_LIBRARY\_PATH=$ORACLE\_HOME/lib:/usr/lib

 

export LC\_CTYPE=en\_US.UTF-8

 

exp mnsh/mnsh@lt211 file=/data/bakper30min.dat tables=\\(curord\\) log=/data/bakper30minExp.log

 

#read the last 2 line of file

new=\`tail -n 2 /data/bakper30minExp.log\`#读取导出的log的最后2行

echo $abc

#read the last 2 line of file

success=\`tail -n 2 /data/bakper30minExpSuccess.log\`#读取导出成功log的最后2行(成功备份的log)

echo $test

if \[ "$new" == "$success" ];then#对比2个是否相等,一般如果出错倒数第2行是错误信息

        echo "Exp success"

        sqlplus mnshbak/mnshbak@orcl @/u/dropPer30min.sql

        imp mnshbak/mnshbak@orcl file=/data/bakper30min.dat fromuser=mnsh touser=mnshbak log=/data/bakper30minImp.log

else

        echo "Exp fail"

fi