Home > Database > Mysql Tutorial > body text

Shell脚本备份恢复Oracle数据库简单示例

WBOY
Release: 2016-06-07 17:07:31
Original
1059 people have browsed it

exp_p.sh #!/bin/sh #$1生成dmp文件保存路径 if [ -d $1 ]; then echo $1 exist #用户名/密码 生成文件名称根据当天

exp_p.sh

#!/bin/sh

#$1生成dmp文件保存路径

if [ -d "$1" ]; then

   echo ""$1" exist "

   #用户名/密码 生成文件名称根据当天日期自动生成,,例如20111128.dmp

   exp test/test file="$1/`date + %Y%m%d`.dmp"

else

#如果制定的文件保存路径不存在则创建文件夹后在导出数据

  mkdir -p "$1"

  exp test/test file="$1/`date + %Y%m%d`.dmp"

fi

chmod +x exp_p.sh

./exp_p.sh /home/Oracle/bak

 

imp_p.sh

#!/bin/sh

#$1导入的dmp文件,例如/home/oracle/bak/20111128.dmp

if [ -f "$1" ]; then

   echo ""$1" exist"

   #导入目标数据库的用户名/密码, fromuser源数据库用户

   imp test/test file="$1" fromuser=test1

else

   echo "ERROR:"$1" does not exist"

fi

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!