Linux automatically backs up Oracle data:
Once a colleague, back and forth operation of the development and production of the database, the results mistakenly deleted the production of the database, the mood I think not ordinary people can understand, although that Oracle can have methods to restore, but not thorough.
Therefore, in the work, whether the development or maintenance, backup database is very necessary.
Simple and practical nightly automatic backup Database small case
Step one, create a backup script, named orabak.sh
#路径名, specify the path to the backup
FILEPATH =/oracle/orabak
#根据指定日期格式, define the backup database filename
filename = ' date +%y%m%d_%h%m
#切换至指定路径, and create a folder
CD $FILEPATH
mkdir $FILENAME
chmod 775 $FILENAME
#oracle变量设置
export user=oracle;
Export ORACLE_SID=ORCL;
Export oracle_home=/oracle/app/oracle/product/11.2.0/dbhome_1;
Export path= $ORACLE _home/bin: $PATH;
#导出数据库 here the exp can be used as needed to use EXPDP
exp SCOTT/TIGER@ORCL file= "$FILENAME". DMP log= "$FILENAME". Log Owner=scott rows=y< c16/> #打包 + compression
CD.
TAR-CF $FILENAME. Tar $FILENAME
rm-rf $FILENAME
gzip $FILENAME. Tar
exit
EOF
Step two, use timed script crontab to automatically invoke backup script
Linux/aix Use the CRONTAB-E command, and then the last line to add a function script, for example:
* * * sh/oracle/orabak/orabak.sh
About the use of crontab under Linux
Minute hour day Month DayOfWeek command
minute-integers from 0 to 59
hour-integers from 0 to 23
Day-an integer from 1 to 31 (must be a valid date for the specified month)
month-integers from 1 to 12 (or months, such as a short or Feb)
DayOfWeek-integers from 0 to 7, 0 or 7 to describe Sunday (or by sun or mon shorthand)
command-commands that need to be executed (can be used as Ls/proc >>/tmp/proc or commands to execute a custom script)
For each of these statements, the asterisk (*) represents all the available values. For example, when referring to a month, the command is expressed on a monthly basis (subject to other restrictions).
The hyphen (-) between integers denotes an integer column, for example 1-4 means an integer 1,2,3,4
Specifies that values are separated by commas. For example: 3,4,6,8 represents these four specified integers.
The symbol "/" specifies the stepping setting. "/" represents a stepping value. If the 0-59/2 definition is executed every two minutes. The stepping value can also be indicated by an asterisk. such as */3 is used to run the specified task every three months.
Thank you for reading, I hope to help you, thank you for your support for this site!