Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement an automatic backup script in Oracle database

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces you how to achieve an automatic backup script in the Oracle database, the content is very detailed, interested friends can refer to, hope to be helpful to you.

I. backup script

1. Initialize the variable and record the start log

# variable sysname= fill in its own system name syspath=/home/oracle/databak/$sysname vault datekeeper $(date'+% Y% m% d% H% M% S') # Log directory logfile=$ {syspath} / backup.$ {v_date} .log # print start time echo backup_time > ${logfile} date'+% Y-%m-%d% Hanger% MRV% S'> > ${logfile} echo "backup jcd" > > ${logfile} echo "start_time" > ${ Logfile} date'>% Y-%m-%d% HV% MV% S'> ${logfile}

2. Enter the oracle directory and set the parameters of oracle

# enter the oracle directory and set the oracle variable cd / home/11g/app/oracle/product/11.2.0 export ORACLE_HOME=/home/11g/app/oracle/product/11.2.0/db_1 export PATH=$PATH:/home/11g/app/oracle/product/11.2.0/db_1/bin export ORACLE_SID=SID name

3. Export data

Echo $syspath vested dates $(date'+% Y% m% d% H% M% S') filename=$syspath/jcd$ {v_date} .dmp # Export Command exp username/password file=$ {filename} compress=n > > ${logfile} echo "end_time" > > ${logfile} date'+% Y-%m-%d% H15% MVO% SV% S'> > ${logfile}

4. Compress dump package

Gzip ${filename}

5. Use scp to transfer the compressed package to the backup server. Note that the directory on the backup server needs to be created in advance.

Scp ${filename} .gz remot_name@remot_ip:/home/weblogic/databak/ backup directory

Second, set the execution time of the script

We set the rule to be executed every day at 2: 00 a. M., using crontab for processing.

Execute crontab-e and set the following rules:

02 * sh / home/oracle/db.sh on how to implement an automatic backup script in the Oracle database is shared here. I hope the above content can be of some help and learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report