“Oracle定时备份”的版本间的差异
跳到导航
跳到搜索
docker>Evan (→导入) |
小 (导入1个版本) |
2019年10月14日 (一) 13:52的最新版本
脚本如下
导出
cat dbexp #!/bin/bash # 02 16 * * 0 /bin/bash -x /home/oracle/evan/dbexp #user is oracle not root 星期天时备份并拉回内网 source /etc/profile PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/home/oracle/app/oracle/product/11.2.0/dbhome_1/bin export PATH export ORACLE_HOME="/home/oracle/app/oracle/product/11.2.0/dbhome_1" export ORACLE_SID=xtwl cd /home/oracle/evan rm -f evandb.dmp #/home/oracle/app/oracle/product/11.2.0/dbhome_1/bin/exp ZTGO0815/ZTGO0815@xtwl file=/home/oracle/evan/evandb.dmp owner=ZTGO0815 exp O085\/O085\@xtwl file=./evandb.dmp owner=O085
导入
#!/bin/bash source /etc/profile PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/home/oracle/app/oracle/product/11.2.0/dbhome_1/bin export PATH export ORACLE_HOME="/home/oracle/app/oracle/product/11.2.0/dbhome_1" export ORACLE_SID=xtwl # cd /home/oracle/evan #oracle bak DATE=$(date +%Y%m%d%H%M) exp O0815/O0815@xtwl file=evandb${DATE}.dmp owner=O0815 rm -f evandb.dmp testdb.tar.bz2 rsync -avz --progress [email protected]:/home/oracle/evan/testdb.tar.bz2 testdb.tar.bz2 tar xvf testdb.tar.bz2 imp O0815/O0815@xtwl file=./evandb.dmp log=./imp.log fromuser=O0815 touser=O0816
trouble
手工执行脚本可以备份 而放在定时任务不行,查看cron log tail /var/spool/mail/oracle Copyright (c) 1982, 2011, Orac Invalid(无效的) format of Export utility name Verify that ORACLE_HOME is properly (正确)set Export terminated unsuccessfully EXP-00000: Message 0 not found; No message file for product=RDBMS, facility=EXP+ touch lock [oracle@db evan]$ echo $ORACLE_HOME /home/oracle/app/oracle/product/11.2.0/dbhome_1 $ echo $ORACLE_SID xtwl 解决办法在脚本中添加 export ORACLE_HOME="/home/oracle/app/oracle/product/11.2.0/dbhome_1" export ORACLE_SID=xtwl su - oracle 这个没用上