The shared script is tested in the ORACLE11G test environment installed in LINUX. If you want to use it in your own environment, modify the relevant parameters. Use sourcehomeoracle. bash_profi
The shared script is tested in the ORACLE 11g test environment installed in LINUX. If you want to use it in your own environment, modify the relevant parameters. Use source/home/oracle/. bash_profi
1. related parameter introduction:
Command Line Parameters
Description
TARGET
A connection string defined for the target database. when connected to a target database, the connection is continuously SYSDBA. This user has the right to start and shut down the database. It must belong to the OSDBA group and create a password file to allow SYSDBA connection.
CATALOG
Connect to the recovery directory.
NOCATALOG
Do not use Restore directory. Mutually Exclusive with CATALOG Parameters
Upload File
A string that defines the name of the output command file. When running RMAN, you can run command files or interactive operations.
LOG & MSGLOG
Defines the string of the file that contains the output information of RMAN. The LOG parameter can only be used in command lines. SPOOLING cannot be started in RMAN. When the application log file is used, the output information is not displayed on the screen.
TRACE
Similar to the log parameter, a file that displays the input information of RMAN is generated. TRACE is also displayed on the screen.
APPEND
Special usage: If a message log file exists, the message is appended to the file. Often used together with LOG
Note: The shared script has been tested in the Oracle 11g test environment installed in LINUX. If you use it in your own environment, modify the relevant parameters. Use the source/home/oracle/. bash_profile statement to ensure successful execution in LINUX scheduled tasks. If you need to use it in windows, modify it as appropriate.
2. Only archive files are backed up and the backup directory and file format are specified.
Specifies the location and format of the generated logs and backup files. The log format is similar to this: rman-arch20130912-1634.log
[Oracle @ bys001 ~] $ Cat archback. sh
#! /Bin/sh
Source/home/oracle/. bash_profile
/U01/app/oracle/product/11.2.0/dbhome_1/bin/rman log/home/oracle/rman-arch 'date + % Y % m % d-% H % m'. log < Connect target /;
Run {
Backup archivelog all delete input
Format '/backup/archlog/arch _ % d _ % T _ % s ';
}
Exit
3. Full-Database Backup scripts, including archive logs and control files and SPFILE parameter files
[Oracle @ bys001 ~] $ Cat fullback. sh
#! /Bin/sh
Source/home/oracle/. bash_profile
/U01/app/oracle/product/11.2.0/dbhome_1/bin/rman log/home/oracle/backfull-'date + % Y % m % d-% H % M '. log < Connect target /;
Run {
Backup full tag 'bys001-full' database
Format "/backup/full/bys001full _ % d _ % t _ % s"
Plus archivelog
Format "/backup/full/bys001arch _ % d _ % t _ % s"
Delete all input;
}
Exit
4. Differential incremental Differential backup script-0, 1, and 2 levels %. This is the default Incremental backup mode.
[Oracle @ bys001 ~] $ Cat back0.sh
#! /Bin/sh
Source/home/oracle/. bash_profile
######## Rman-back level0
Rman log/home/oracle/back0-'date + % Y % m % d-% H % M'. log < Connect target /;
Run {
Backup incremental level = 0 tag 'bys001-0' database
Format "/backup/full/bys001full _ % d _ % t _ % s"
Plus archivelog
Format "/backup/full/bys001arch _ % d _ % t _ % s"
Delete all input;
}
Exit
Level 1 incremental differential backup script
[Oracle @ bys001 ~] $ Cat back1.sh
#! /Bin/sh
Source/home/oracle/. bash_profile
######## Rman-back level 1
##########
Rman log/home/oracle/back1-'date + % Y % m % d-% H % M'. log < Connect target /;
Run {
Backup incremental level = 1 tag 'bys001-1' database
Format "/backup/full/bys001full _ % d _ % t _ % s"
Plus archivelog
Format "/backup/full/bys001arch _ % d _ % t _ % s"
Delete all input;
}
Exit
Level 2 incremental differential backup script
[Oracle @ bys001 ~] $ Cat back2sh
#! /Bin/sh
Source/home/oracle/. bash_profile
######## Rman-back level 2
Rman log/home/oracle/back2-'date + % Y % m % d-% H % M'. log < Connect target /;
Run {
Backup incremental level = 2 tag 'bys001-2' database
Format "/backup/full/bys001full _ % d _ % t _ % s"
Plus archivelog
Format "/backup/full/bys001arch _ % d _ % t _ % s"
Delete all input;
}
Exit
5. cumulative incremental backup-there are 0, 1, 2 3 levels of 0 cumulative incremental backup script
#! /Bin/sh
Source/home/oracle/. bash_profile
######## Rman-back level 0 --- cumulative
Rman log/home/oracle/back0-'date + % Y % m % d-% H % M'. log < Connect target /;
Run {
Backup incremental level = 0 cumulative tag 'bys001-0' database
Format "/backup/full/bys001full _ % d _ % t _ % s"
Plus archivelog
Format "/backup/full/bys001arch _ % d _ % t _ % s"
Delete all input;
}
Exit
Backup script
#! /Bin/sh
Source/home/oracle/. bash_profile
######## Rman-back level 1 -- cumulative
Rman log/home/oracle/back1-'date + % Y % m % d-% H % M'. log < Connect target /;
Run {
Backup incremental level = 1 cumulative tag 'bys001-1' database
Format "/backup/full/bys001full _ % d _ % t _ % s"
Plus archivelog
Format "/backup/full/bys001arch _ % d _ % t _ % s"
Delete all input;
}
Exit
Level 2 cumulative incremental backup script
This script uses the service name to log on to RMAN. It is best to first use connect target sys/sys@192.168.1.212: 1521/bys001 in RMAN; Confirm that the login is normal and then write the script.
Of course, you can also use rman target sys/sys @ bys001
#! /Bin/sh
Source/home/oracle/. bash_profile
######## Rman-back level 2 --- cumulative
Rman log/home/oracle/back2-'date + % Y % m % d-% H % M'. log < Connect target sys/sys@192.168.1.212: 1521/bys001;
Run {
Backup incremental level = 2 cumulative tag 'bys001-2' database
Format "/backup/full/bys001full _ % d _ % t _ % s"
Plus archivelog
Format "/backup/full/bys001arch _ % d _ % t _ % s"
Delete all input;
}
Exit
Recommended reading:
Basic Oracle tutorial-copying a database through RMAN
Reference for RMAN backup policy formulation
RMAN backup learning notes
Oracle Database Backup encryption RMAN Encryption