{"id":6967,"date":"2017-09-06T11:44:52","date_gmt":"2017-09-06T03:44:52","guid":{"rendered":"http:\/\/rmohan.com\/?p=6967"},"modified":"2017-09-06T11:44:52","modified_gmt":"2017-09-06T03:44:52","slug":"oracle-backup","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6967","title":{"rendered":"oracle backup"},"content":{"rendered":"<p>#!\/bin\/bash<br \/>\n#oracle_backup.sh version1.0 chmod 700<br \/>\n#00 00 * * * \/usr\/local\/scripts\/oracle_backup.sh<br \/>\n#chmod 700 \/usr\/local\/scripts\/oracle_backup.sh<br \/>\n#You must first import the environment variables in the Oracle user&#8217;s bash_profile file<br \/>\n#Must be used to define the DBA account first dpdata1 path and authorized directory to read and write, modify the dpdata1 group<\/p>\n<p>export ORACLE_BASE=\/usr\/local\/u01\/oracle<br \/>\nexport ORACLE_HOME=\/usr\/local\/u01\/oracle\/product\/11.2.0\/dbhome_1<br \/>\nexport ORACLE_SID=oracle11<br \/>\nexport LD_LIBRARY_PATH=$ORACLE_HOME\/lib<br \/>\nexport PATH=$ORACLE_HOME\/bin:$PATH<br \/>\ndatetime=$(date +&#8221;%Y%m%d&#8221;)<br \/>\ndpdata1_dir=&#8221;\/data\/backup\/oracle_backup&#8221;<br \/>\noracle_u01=&#8221;u01&#8243;<br \/>\noracle_u02=&#8221;u02&#8243;<br \/>\noracle_password1=&#8221;u01_password&#8221;<br \/>\noracle_password2=&#8221;u02_password&#8221;<\/p>\n<p>expdp ${oracle_u01}\/${oracle_password1} directory=dpdata1 dumpfile=${oracle_u01}_${datetime} logfile=${oracle_u01}_${datetime}.log<\/p>\n<p>if [ $? -ne 0 ];then<br \/>\n    echo &#8220;$(date +&#8221;%Y-%m-%d_%H:%M:%S&#8221;)oracle_${oracle_u01}_backup_file!&#8221; > ${dpdata1_dir}\/${datetime}_err.log<br \/>\nfi<\/p>\n<p>expdp ${oracle_u02}\/${oracle_password2} directory=dpdata1 dumpfile=${oracle_u02}_${datetime} logfile=${oracle_u02}_${datetime}.log<\/p>\n<p>if [ $? -ne 0 ];then<br \/>\n    echo &#8220;$(date +&#8221;%Y-%m-%d_%H:%M:%S&#8221;)oracle_${oracle_u02}_backup_file!&#8221; >> ${dpdata1_dir}\/${datetime}_err.log<br \/>\nfi<\/p>\n<p>\/usr\/bin\/bzip2 -z ${dpdata1_dir}\/*${datetime}*<br \/>\nfind $dpdata1_dir -type f -ctime +30 -name &#8220;*.bz2&#8221; -exec rm -vf {} \\;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>#!\/bin\/bash #oracle_backup.sh version1.0 chmod 700 #00 00 * * * \/usr\/local\/scripts\/oracle_backup.sh #chmod 700 \/usr\/local\/scripts\/oracle_backup.sh #You must first import the environment variables in the Oracle user&#8217;s bash_profile file #Must be used to define the DBA account first dpdata1 path and authorized directory to read and write, modify the dpdata1 group<\/p>\n<p>export ORACLE_BASE=\/usr\/local\/u01\/oracle export ORACLE_HOME=\/usr\/local\/u01\/oracle\/product\/11.2.0\/dbhome_1 export ORACLE_SID=oracle11 [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6967"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6967"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6967\/revisions"}],"predecessor-version":[{"id":6968,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6967\/revisions\/6968"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6967"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6967"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6967"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}