Rman backup script rman shell script editing is first tested in rman to check whether the backup is normal. The statement is being judged. Backup script sh command export target/msglog =/oracle/ora10g/rmanbak/bakl0.log export file =/oracle/ora10g/rmanbak/script/export target/msglog =/oracle/ora10g/rmanbak/ bakl1.log prepare file =/oracle/ora10g/rmanbak/script/empty target/msglog =/oracle/ora10g/rmanbak/bakl2.log prepare file =/oracle/ora10g/rmanbak/script/empty rman script full backup script (execute full backup once every month) [oracle @ redhat script] $ Cat full_bak. SQL run {allocate channel c1 type disk; SQL 'alter system archive log current '; backup full tag 'order' databaseinclude current controlfile format'/oracle/ora10g/rmanbak/fullback _ % d _ % T _ % s' plus archivelog format'/oracle/ora10g/rmanbak/ bakarch _ % d _ % T _ % s' delete all input; delete obsolete; release channel c1;} backup cat rman_bak_l0.sqlrun {allocate channel cha1 type disk; backupincremental level 0 format "/oracle/ora10g/rmanbak/inc0 _ % u _ % T" tag wolf_inc0database; release channel cha1;} level 1 backup cat rman_bak_l1.sqlrun {allocate channel cha1 type disk; backupincremental level 1 format "/oracle/ora10g/rmanbak/inc0 _ % u _ % T" tag wolf_inc1database; release channel cha1;} 2-level backup cat rman_bak_l2.sqlrun {allocate channel cha1 type disk; backupincremental level 2 format "/oracle/ora10g/rmanbak/inc0 _ % u _ % T" tag wolf_inc2data Base; release channel cha1;} executes level 0 backups every Sunday, level 1 backups on Wednesday, and level 2 backups on the rest of the time. The shell script is as follows: [oracle @ redhat script] $ cat startrman. sh #! /Bin/bashexport TMP =/tmpexport TMPDIR = $ TMPexport ORACLE_BASE =/oracle/ora10gexport ORACLE_HOME = $ ORACLE_BASE/product/10.2.0/db_1export ORACLE_SID = wolfexport ORACLE_TERM = xtermexico port PATH =/usr/sbin: $ PATHexport PATH = $ ORACLE_HOME/bin: $ PATHexport LD_LIBRARY_PATH = $ ORACLE_HOME/lib:/lib64:/usr/lib64:/usr/local/lib64: /usr/x11R6/lib64export CLASSPATH = $ ORACLE_HOME/JRE: $ ORACLE_HOME/jlib: $ ORACLE_HOME/rdbms/jlibex Port LD_ASSUME_KERNEL = 2.6.18export NLS_LANG = "SIMPLIFIED CHINESE_CHINA.UTF8" export PATH =/oracle/ora10g/product/10.2.0/db_1/bin:/usr/sbin:/usr/lib/qt-3.3/bin: /usr/kerberos/bin:/usr/local/bin:/usr/bin: /home/oracle/binSH_HOME =/oracle/ora10g/rmanbakexport SH_HOMEDATE = 'date + "% Y % m % d-% H % M" 'Week = 'date + "% w "'# ------------------------------------- # confirm whether the oracle is runing #------------------ ------------------- Ps-ef | grep dbw0 _ $ ORACLE_SID | grep-v grep>/dev/null # begin to backup # ------------------------------------- if [$? -Eq 0]; then if [$ week = "0"]; then rman target/@ $ SH_HOME/script/rman_bak_l0. SQL log = $ SH_HOME/logs/oraclel0 $ DATE. log else if [$ week = "3"]; then rman target/@ $ SH_HOME/script/rman_bak_l1. SQL log = $ SH_HOME/logs/oraclel1 $ DATE. log else rman target/@ $ SH_HOME/script/rman_bak_l2. SQL log = $ SH_HOME/logs/oraclel1 $ DATE. run the cron File Syntax for the crontabroot task scheduled by logfififi: commands for hours, days, months, and weeks 0-59 0-23 1-31 1-12 0-6 c Ommand (value range, 0 indicates that a job is usually mapped to a row on Sunday) use the root user to edit crontab-e-u oracle to specify the oracle user to edit the scheduled task [oracle @ redhat script] $ crontab-l30 3 ***/oracle/ora10g/rmanbak/script/ startrman. sh>/oracle/ora10g/rmanbak/script/crontab. the knowledge of log shell scripts is incomplete. I asked a friend to solve the problem. Of course, it is best to systematically learn the basic knowledge of shell scripts (you can check whether shell programs can be executed in segments) pay attention to the punctuation mark judgment statement. First, check whether the statement exists, then run the following command [oracle @ redhat/] $ cat 3.sh ps-ef | grep dbw0 _ $ ORACLE_SID | grep-v grep>/dev/nullif [$? -Eq 0]; then echo "oracle backup begin" else echo "oracle_sid error" exit 1fi [oracle @ redhat/] $ ps-ef | grep dbw0 _ $ ORACLE_SID | grep-v grep>/dev /nullif [$? -Eq 0]; then echo "oracle backup begin" else echo "oracle_sid error" exit 1 This 1 can be passed to echo $? Indicates whether the command is successfully executed. fi [oracle @ redhat/] $ cat 2.sh ps-ef if [$? -Eq 0]; thenecho 0000000fi [oracle @ redhat/] $ echo $? It can be used to check whether the previous command is correct. If the normal output is 0, if the error is 1 DATE = 'date + "% Y % m % d" ', you can test week = 'date + "% w"' one by one in the system "'[ oracle @ redhat script] $ cat 22222.sh DATE = 'date + "% Y % m % d" 'Week = 'date + "% w" 'echo $ DATEecho $ weekif [$ week = 0]; thenecho 0000000000000 else echo errorfi