Get the App
SLTechnology News&Howtos  ›  Database  › 

How to implement RMAN full backup and incremental backup shell script under Linux platform

Shulou Source: shulou.com Published: 2022-05-31 14:22:30 09月19日 Update

This article mainly introduces how to achieve RMAN full and incremental backup shell script under the Linux platform, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to know about it.

Full script

Take the nocatalog mode as an example:

Shell script:

#

# # hot_database_backup.sh # #

# # created by Tianlesoftware # #

# # 2010-7-16 # #

#

#! / bin/sh

#-

# Determine the user which is executing this script.

#-

CUSER= `id | cut-d "("-f2 | cut-d ")"-f1`

#-

# Put output in .out. Change as desired.

# Note: output directory requires write permission.

#-

RMAN_LOG_FILE=$ {0} .out

#-

# You may want to delete the output file so that backup information does

# not accumulate. If not, delete the following lines.

#-

If [- f "$RMAN_LOG_FILE"]

Then

Rm-f "$RMAN_LOG_FILE"

Fi

#-

# Initialize the log file.

#-

Echo > > $RMAN_LOG_FILE

Chmod 666 $RMAN_LOG_FILE

#-

# Log the start of this script.

#-

Echo Script $0 > > $RMAN_LOG_FILE

Echo = started on `date` = > > $RMAN_LOG_FILE

Echo > > $RMAN_LOG_FILE

#-

# Oracle home path.

#-

ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1

Export ORACLE_HOME

#-

# the Oracle SID of the target database.

#-

ORACLE_SID=orcl

Export ORACLE_SID

#-

# The Oracle DBA user id (account).

#-

ORACLE_USER=oracle

Export ORACLE_USER

#-

# Set the Oracle Recovery Manager name.

#-

RMAN=$ORACLE_HOME/bin/rman

#-

# Print out the value of the variables set by this script.

#-

Echo > > $RMAN_LOG_FILE

Echo "RMAN: $RMAN" > > $RMAN_LOG_FILE

Echo "ORACLE_SID: $ORACLE_SID" > > $RMAN_LOG_FILE

Echo "ORACLE_USER: $ORACLE_USER" > > $RMAN_LOG_FILE

Echo "ORACLE_HOME: $ORACLE_HOME" > > $RMAN_LOG_FILE

#-

# Print out the value of the variables set by bphdb.

#-

# echo > > $RMAN_LOG_FILE

# echo "NB_ORA_FULL: $NB_ORA_FULL" > > $RMAN_LOG_FILE

# echo "NB_ORA_INCR: $NB_ORA_INCR" > > $RMAN_LOG_FILE

# echo "NB_ORA_CINC: $NB_ORA_CINC" > > $RMAN_LOG_FILE

# echo "NB_ORA_SERV: $NB_ORA_SERV" > > $RMAN_LOG_FILE

# echo "NB_ORA_POLICY: $NB_ORA_POLICY" > > $RMAN_LOG_FILE

#-

# NOTE: This script assumes that the database is properly opened. If desired

# this would be the place to verify that.

#-

Echo > > $RMAN_LOG_FILE

#-

#-

# Call Recovery Manager to initiate the backup.

#-

CMD_STR= "

ORACLE_HOME=$ORACLE_HOME

Export ORACLE_HOME

ORACLE_SID=$ORACLE_SID

Export ORACLE_SID

$RMAN nocatalog target sys/admin msglog $RMAN_LOG_FILE append

Tags: Backup script increment complete article platform command data file time pattern directory different no rough value interest can be passed at the same time instance Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft MariaDB Huawei Xiaomi Shulou Tech Info