First, write the script
vim/home/backup/oraclebk.sh
#! /usr/bin# path name, specifying the path of the backup filepath=/home/backup/oracledata# the backup database filename filename= ' date + '%y%m%d_%h%m ' #切换至指定路径 according to the specified date format, and create a folder CD $FILEPATHmkdir $FILENAMEchmod 775 $FILENAME #oracle variable settings export user=oracle;export oracle_sid=ecology;export Oracle_home=/u01/app/oracle/product/11.2.0/db_1;export path= $ORACLE _home/bin: $PATH; #导出数据库exp ecology/ecology file = "$FILENAME/$FILENAME". DMP log= "$FILENAME/$FILENAME". Log owner=ecology# Package TAR-ZCVF $FILENAME. tar.gz $FILENAMErm-RF $ FILENAMESCP $FILENAME. tar.gz [email protected]: $FILEPATH/find./-mtime +30-name \*.gz |xargs rm-fexiteof
After the script is executed, the backup data is synchronized to 192.168.1.21 the same location on the standby machine
Second, set up the Scheduled tasks
Crontab-e
#备份数据库0 3 * * */bin/bash/home/backup/oraclebk.sh
Service Crond Restart
Oracle Database scheduled backup script