About the idea:
1, divided into different users exp, each user an exp execution file.
2, retention policy
3, call (1,2) two files with a total file.
On Linux
/u02/orabak: A directory for storing DMP files
/U02/SCRIPTS/AUTOEXP: Directory for storing exp these sh scripts
Remember the directory, the file assigned to the appropriate WRX permissions.
AUTOEXP.SH: Automatic backup of the total file, with crontab inside the sh file.
exp_plms.sh: Each user an sh file, the user backs up
exp_weishi.sh: Each user an sh file, the user backs up
DELETE.SH: Retention policy, can be retained for 30 days, arbitrary settings
Autoexp.log: Automatic backup, write a log per user every day
Autoexp.del.log: Keep the policy log and write the deleted file log here.
[Oracle@sr0002sz autoexp]$ Cat exp_plms.sh
#!/bin/sh
#oracle Environment
ORACLE_BASE=/ORA01; Export Oracle_base
Oracle_home= $ORACLE _base/product/11.2.0/dbhome_1; Export Oracle_home
ORACLE_SID=DBSTD; Export Oracle_sid
nls_date_format= ' Yyyy-mm-dd HH24:MI:SS '; Export Nls_date_format
Nls_lang=american_america.zhs16gbk;export Nls_lang
Path= $ORACLE _home/bin:/usr/sbin: $PATH; Export PATH
#exp variable
Userid=oracle
Pwd=iamdba
Oraclesid=dbstd
Bakpath=/u02/orabak
vtoday= ' Date +%y%m%d '
#run Exp Scripts Log
Logpath=/u02/scripts/autoexp
Logfile=autoexp.log
#exp command belong to,this should be changed using Oracle User
Owner=plms
#exp Combination
Datatype=full
Data_name=${oraclesid}_${owner}_${datatype}_${vtoday}.dmp
Log_name=${oraclesid}_${owner}_${datatype}_${vtoday}.log
#exp Log
Echo-e "n" >>${logpath}/${logfile}
echo "------Start@${oraclesid}_${owner}---------" >>${logpath}/${logfile}
Echo ' Date ' start exp backup: $bakpath/$data _name >>${logpath}/${logfile}
#exp command
Exp $userid/$pwd @ $oraclesid file= $bakpath/$data _name wner= $owner direct=y compress=y rows=n consistent=y buffer= 100000000 log= $bakpath/$log _name
#exp Log
echo ' Date ' end exp Backup: $bakpath/$log _name >>${logpath}/${logfile}
echo "-------End@${oraclesid}_${owner}----------" >>${logpath}/${logfile}
[Oracle@sr0002sz autoexp]$ Cat exp_weishi.sh
#!/bin/sh
#oracle Environment
ORACLE_BASE=/ORA01; Export Oracle_base
Oracle_home= $ORACLE _base/product/11.2.0/dbhome_1; Export Oracle_home
ORACLE_SID=DBSTD; Export Oracle_sid
nls_date_format= ' Yyyy-mm-dd HH24:MI:SS '; Export Nls_date_format
Nls_lang=american_america.zhs16gbk;export Nls_lang
Path= $ORACLE _home/bin:/usr/sbin: $PATH; Export PATH
#exp variable
Userid=oracle
Pwd=iamdba
Oraclesid=dbstd
Bakpath=/u02/orabak
vtoday= ' Date +%y%m%d '
#run Exp Scripts Log
Logpath=/u02/scripts/autoexp
Logfile=autoexp.log
#exp command belong to,this should be changed using Oracle User
Owner=weishi
#exp Combination
Datatype=full
Data_name=${oraclesid}_${owner}_${datatype}_${vtoday}.dmp
Log_name=${oraclesid}_${owner}_${datatype}_${vtoday}.log
#exp Log
Echo-e "n" >>${logpath}/${logfile}
echo "------Start@${oraclesid}_${owner}---------" >>${logpath}/${logfile}
Echo ' Date ' start exp backup: $bakpath/$data _name >>${logpath}/${logfile}
#exp command
Exp $userid/$pwd @ $oraclesid file= $bakpath/$data _name wner= $owner direct=y compress=y rows=n consistent=y buffer= 100000000 log= $bakpath/$log _name
#exp Log
echo ' Date ' end exp Backup: $bakpath/$log _name >>${logpath}/${logfile}
echo "-------End@${oraclesid}_${owner}----------" >>${logpath}/${logfile}
[Oracle@sr0002sz autoexp]$ Cat delete.sh
#!/bin/sh
#set Backup Path
Bakpath=/u02/orabak
#set Delete files log path and file log
Delpath=/u02/scripts/autoexp
Dellog=autoexp.del.log
#run, keep
Find ${bakpath}-mtime +30-exec Ls-la {}; >>${delpath}/${dellog}
Find ${bakpath}-mtime +30-exec rm {}; >>${delpath}/${dellog}
[Oracle@sr0002sz autoexp]$ Cat autoexp.sh
#!/bin/sh
#set Exp Command Path
Scriptspath=/u02/scripts/autoexp
#oracle Exp Backup
SH ${scriptspath}/exp_weishi.sh
SH ${scriptspath}/exp_plms.sh
#backup Retention Policy
SH ${scriptspath}/delete.sh
Finally, let autoexp.sh do it once a day. Use Crontab.
Basic format:
* * * * * user command
Time-sharing time and Moon Week user command
Su-root
Vi/etc/crontab, add
* * * * oracle/u02/scripts/autoexp/autoexp.sh >/u02/scripts/autoexp/autoexp.cron.log 2>&1
23:00 every night.
On Windows
Thinking, just windows command commands are a little different.
1,exp_plms.bat
:: Setting Oracle Environment variables
Set Userid=oracle
Set PWD=IAMDBA
Set RACLESID=DBSTD
Set Bakpath=d:orabak
:: Set Export user
Set Wner=plms
:: Set time Format Vtoday=yyyymmddhh24mi
Set vtoday=%date:~0,4%%date:~5,2%%date:~8,2%
::%time:~0,2%%time:~3,2%
::
::
:: Export all user data
Set Datatype=full
Exp%userid%/%pwd%@%oraclesid% file=%bakpath%%oraclesid%_%owner%_%datatype%_%vtoday%.dmp wner=%owner% direct=y Compress=y rows=y consistent=y buffer=100000000 log=%bakpath%%oraclesid%_%owner%_%datatype%_%vtoday%.log
::
2,delete.bat
:: Delete data from n days before backup
forfiles/p "D:orabak"/s/m *.*/d-7/C "cmd/c del @path"
3.autoexp.bat
:: Perform exp backup
Set Scriptspath=d:scriptsautoexp
Call%scriptspath%exp_plms.bat
Call%scriptspath%delete.bat
Finally, create a new execution plan under Windows, which is executed on the first day.