Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Oracle backs up scripts in expdp mode

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Requirements: backup oracle database and upload data backup files to ftp server

ftp server IP address: 192.168.6.9

ftp server account/password: test/test2019

1. Oracle user creates backup script path:

#su - oracle

$ mkdir /u0/app/backup/bin

$ cd /u01/app/backup/bin

2. Create a backup script:

$ vi /u01/app/backup/bin/bak.sh

#!/ bin/sh

#Specify your own environment variables (suitable for multi-instance databases)

export ORACLE_SID=orcl

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1

export PATH=$ORACLE_HOME/bin:$PATH:/sbin/

expot.UTF-8

export NLS_LANG='AMERICAN_AMERICA.AL32UTF8'

#or use environment variables in oracle's original.bash_profile file

source /home/oracle/.bash_profile

#Choose one of the above environment variables

timedate=$(date +%Y%m%d%H%M%S)

bakdbname=hb

bakdbpasswd=h2234

dumpbame=hd

bakdbhome=/u01/app/backup

expdp $bakdbname/$bakdbpasswd directory=backDir dumpfile=$dumpbame-$timedate.dmp logfile=$bakdbname-$timedate.log

#Method 1: Compress dmp files, which will be compressed together with directories and files connected to bakdbhome variables

zip -r $bakdbhome/$dumpbame-$timedate.zip $bakdbhome/$dumpbame-$timedate.dmp $bakdbhome/$bakdbname-$timedate.log #compress dmp files and log files

Or use method 2

#If you do not add the project path directory name, switch to the directory where the dmp file is stored for compression

cd $bakdbhome

zip -r $dumpbame-$timedate.zip $dumpbame-$timedate.dmp $bakdbname-$timedate.log

find $bakdbhome/*.log -mtime +10 -exec rm -rf {} \;

find $bakdbhome/*.zip -mtime +10 -exec rm -rf {} \;

find $bakdbhome/*.dmp -exec rm -rf {} \; #Delete the original dmp file after compressing the front

cd $bakdbhome #Switch to the backup file directory (if you use method 2 here, you don't need to switch directories)

ftp -v -n 192.168.6.9 >${bakdbname}_${timedate}.log >${dumpdbname}_${timedate}.log

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report