Linux Shell crontab EXPDP scheduled Task logical backup

Source: Internet
Author: User
Tags create directory

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.