Create SH Script
[Email protected] ~]$ VI logicbackup.sh
Add script Content
#!/bin/sh# ###################################################################Powered by Ironfo# ###################################################################Oracle Environment Settingsoracle_base=/usr/local/Oracle; Export Oracle_baseoracle_home=$ORACLE _base/product/11.2.0/dbhome_1; Export Oracle_home PATH=$ORACLE _home/bin:/usr/local/bin:/usr/ccs/bin:$PATH:/usr/Sbinexport Pathclasspath=$ORACLE _home/jlib:$ORACLE _home/product/jlib; export Classpathbackup_dir=/usr/local/oracle/admin/orcl/Dpdump#You can create a data pump directory, where you specify the default directory#sql>create DIRECTORY dump_backup_dir as '/u01/oradata/dump_backup_dir ';#sql>grant read,write on directory dump_backup_dir to user; dmp_file=ph_$ (Date +%y%m%d_%h%m%S). Dmplog_file=ph_$ (Date +%y%m%d_%h%m%S). Log##Let's start with an export of the databaseEXPDP User/[email protected] Schemas=schema_name dumpfile=$DMP _filelogfile=$LOG _filecompression=All ;#EXPDP user/[email protected] schemas=schema_name directory= $dump _backup_dir dumpfile= $DMP _file logfile= $LOG _file Compression=all parallel=3;#Here are 2 instructions, username and password for your own, I am here to backup table space. #Parallel This parameter is to control the degree of parallelism, the default is 1, but for the database is relatively large, you can set the parallel, which can be less backup#time, but setting up parallelism consumes CPU resources, and if CPU resources are strained, don't set it up. ##Just to is safe (with space), we'll compress the export file#compress dmp files, less space occupied#Compress *.dmp##Let's delete the backups and logs that is more than 1#Delete dmp files beginning with ph_ 2 days ago#Cd$backup _dirFind$backup _dir-mtime +2-name"ph_*"-exec RM- F {} \;#That ' s all
: Wq Save and exit
Add a Scheduled task
[[email protected] ~]$ crontab-e# Execute error message every 6 hours will be output to Tmp/expdp.log file * */6 * * */home/oracle/l ogicbackup.sh >/tmp/expdp.log 2>&1
View Tasks
[Email protected] ~]$ crontab-L* */6 * * */home/oracle/logicbackup.sh >/tmp/expdp.log 2>&1[Orac Le
Crontab-r Deleting a scheduled task
The use of crontab under Linux
Linux Shell crontab EXPDP scheduled Task logical backup