RMAN automatic backup script on LINUX

Source: Internet
Author: User
1. create the backup directory oradataback, level 2 directory archback (archive log), rmanscripts (backup script), and rmanlevel0.shrmanlevel1 under rmanscripts. shrmanlevel2.sh File: mkdiroradataback -- home/oracle/app/ora...

1. create the backup directory oradataback, level 2 directory archback (archback), rmanscripts (backup script ),
Create the rmanlevel0.sh rmanlevel1.sh rmanlevel2.sh file under rmanscripts:
Mkdir oradataback
-- Home/oracle/app/oradataback
Chmod 775 oradataback
Chown-R oracle: oinstall/home/oracle/app/oradataback
Touch rmanlevel0.sh rmanlevel1.sh rmanlevel2.sh
Same as above
2. vi edit three files:
Backup File Level 0:
-- Rmanlevel0.sh --
#! /Bin/sh
# Set porfile_env
Export ORACLE_SID = eytdbs # rman level0 backup
Rman log = '/home/oracle/app/oradataback/db_rman0.log' append < Connect target /;
Run
{
Allocate channel c1 type disk;
Backup as compressed backupset incremental level = 0 database format'/home/oracle/app/oradataback/db_level0 _ % T _ % u' tag = 'level0 ';
SQL 'alter system archive log current ';
Backup archivelog all format'/home/oracle/app/oradataback/archback/db_arch _ % T _ % u' delete input;
Release channel c1;
}
EOF
Level 1 backup file:
-- Rmanlevel1.sh --
#! /Bin/sh
# Set porfile_env
Export ORACLE_SID = eytdbs # rman level0 backup
Rman log = '/home/oracle/app/oradataback/db_rman1.log' append < Connect target /;
Run
{
Allocate channel c1 type disk;
Backup incremental level = 1 database format'/home/oracle/app/oradataback/db_level1 _ % T _ % u' tag = 'level1 ';
SQL 'alter system archive log current ';
Backup archivelog all format'/home/oracle/app/oradataback/archback/db_arch _ % T _ % u' delete input;
Release channel c1;
}
EOF
Level 2 backup file:
-- Rmanlevel2.sh --
#! /Bin/sh
# Set porfile_env
Export ORACLE_SID = eytdbs # rman level0 backup
Rman log = '/home/oracle/app/oradataback/db_rman2.log' append < Connect target /;
Run
{
Allocate channel c1 type disk;
Backup incremental level = 2 database format'/home/oracle/app/oradataback/db_level2 _ % T _ % u' tag = 'level2 ';
SQL 'alter system archive log current ';
Backup archivelog all format'/home/oracle/app/oradataback/archback/db_arch _ % T _ % u' delete input;
Release channel c1;
}
EOF
# Note: run the script command in oracle: sh rmanlevel2.sh
3. add automatic task execution:
Set in root and use vi to edit: # crontab-e
0 2 1 ** su-oracle-c/home/oracle/app/oradataback/rmanscripts/rmanlevel0.sh // Run level 0 backup at on the first day of each month
0 2 ** 0 su-oracle-c/home/oracle/app/oradataback/rmanscripts/rmanlevel1.sh // run Level 1 backup at every Sunday
0 2 ** 1-6 su-oracle-c/home/oracle/app/oradataback/rmanscripts/rmanlevel2.sh // run Level 2 incremental backup at every Monday and Saturday
-- View the added task: crontab-l
-- Crontab format:
Minutes | hours | day of month | day of week |
-- Start crond:
/Sbin/service crond start // start the service
/Sbin/service crond stop // close the service
/Sbin/service crond restart // restart the service
/Sbin/service crond reload // reload the configuration
4. test results:
It can be run automatically and data can be backed up successfully, but it is a small problem,
First, the rman backup format % F has always used this format, but since we do not know it today, we can only change it to _ % T _ % u'. I do not know why.
Second, several errors are reported:
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "identifier": expecting one :"......{,"
RMAN-01008: the bad identifier was: EOF
RMAN-01007: at line 1 column 1 file: standard input
I haven't found any problem after searching for a long time. I will study it later.

Author "srsunbing"

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.