Get the App
SLTechnology News&Howtos  ›  Database  › 

Compression and remote backup of oracle RMAN backup set through shell script

Shulou Source: shulou.com Published: 2022-06-01 14:52:22 10月01日 Update

1. Background description

The company tape library is broken. Where do I put the backup of oracle every day?

2. Re-plan the backup mode

Original backup mode

Current backup mode

3. Backup script sharing

Xiaobai wrote a backup shell script and shared it.

#! / bin/bash# tar oraclebackup file # check RMAN is run?# I always create a RMAN log when I make a RMAN backup, so this log can determine whether my RMAN has executed filename= "/ mnt/rman/log/RmanBackup_ `log +% m% d`.log" comparedata= "Recovery Manager complete." if [- e $filename] Then echo "`date`RMAN is run" & > > / OPS/tarlogelse echo "`date` RMAN is not run,please check" & > > / OPS/tarlog exit 1fi# check RMAN is OK?# judges whether the RMAN backup is successful by judging the final result of my log. If it is not successful, I do not need to back up data= `tail-1$ filename`if ["$data" = "$comparedata"] Then echo "`date` Rman backup sucess" & > > / OPS/tarlogelse echo "`date` Rman backup fail" & > > / OPS/tarlog exit 2fi# tar backupfile and move to backupserver# compresses the backup set of the day and move it to the folder provided by nfs. After my 300GB backup is compressed, it is only 30 GB, and the compression ratio is still amazing / usr/bin/find / mnt/rman-name 'oradb1*' > / OPS/tarlistfor I in `/ bin/cat / OPS/ tarlist`. Do echo "`date` tar $I start" & > > / OPS/tarlog tar-zcvf $i.tar.gz $I & > > / OPS/tarlog doneif [$?-eq 0]; then echo "`date` tar end success" & > > / OPS/tarlog mv / mnt/rman/*.tar.gz / oraclebackup if [$?-eq 0] Then echo "`date`move to oraclebackup fail" & > > / OPS/tarlog else echo "`date`move to oraclebackup fail" & > > / OPS/tarlog fielse echo "`date`tar fail" & > / OPS/tarlogfi

Tags: Backup mode log script success amazing necessary will create company file folder time tape tape library result background or rookie planning remote Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Huawei Linux OPPO Reno Docker