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 set up automatic backup of Oracle database in Linux

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Brief introduction

Oracle Database, also known as Oracle RDBMS, or Oracle for short. It is a relational database management system of Oracle. It is a leading product in the field of database. It can be said that Oracle database system is a popular relational database management system in the world at present. The system has good portability, easy to use and strong function, and is suitable for all kinds of large, medium, small and microcomputer environments. It is a database scheme with high efficiency, good reliability and high throughput.

Characteristics

1. Complete data management functions: 1) large amount of data 2) persistence of data preservation 3) sharing of data 4) Reliability of data 2, products of complete relationships: 1) Information criteria-all information in a relational DBMS should be logically expressed in one way, that is, the values in the table are explicitly expressed. 2) guidelines for ensuring access 3) guidelines for view update-as long as the data in the table that forms the view changes, the data in the corresponding view changes at the same time. 4) data physical and logical independence criteria 3. Distributed processing functions: ORACLE database has provided distributed processing capabilities since version 5, and will have relatively perfect distributed database functions by version 7. An ORACLE distributed database consists of oraclerdbms, sql*Net, SQL*CONNECT, and other non-ORACLE relational products. 4. The operation of data warehouse can be easily realized with ORACLE.

one。 First find the environment variable of the database

If you are under a root account, you must first log in to the account where the database is located.

Su oraclecat / .bash_profile

Export PATHexport ORACLE_BASE=/home/nnc_db/appexport ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1export PATH=$PATH:$ORACLE_HOME/binexport ORACLE_SID=orcl

The environment variable has been found!

two。 Edit the backed up script file

Vi bak.sh

Copy and paste the environment variables into the bak.sh first

Then define a variable date (its function is to name the files that are backed up every day for easy identification), and use the expdp command to export the database as follows:

Date=$ (date +% Y%m%d) expdp database account / database password @ database instance name dumpfile=$ {date} _ db_auto_backup.dmp schemas= database account name compression=all

Exit save.

three。 Set up scheduled tasks using the crontab command of Linux

Crontab-e

The role of crontab-e is to set up scheduled tasks using a text editor (the specific usage of crontab will not be discussed here)

Enter it in a text editor after input

0 0 * / home/nnc_db/bak.sh

The above code means that the bak.sh pieces under / home/nnc_db executed at 00:00 every day, that is, the files created in step 2, need to be adjusted according to their own backup time and file directory.

Then restart the crond service

Service crond restart

four。 Test whether the task runs successfully

According to the information I collected on the Internet, a friend said that the crontab-e setting will not take effect three minutes after the setting is successful! That is to say, if you set up a task at 10:00 in the morning and want to test whether it can be successful, set the next scheduled task to 10:02, there may be a problem! But here I use

* / home/nnc_db/bak.sh

Set to run every minute, and there is no problem. There is also a novice pit is that you directly run the script file will output a detailed process on the command line, while setting a scheduled task to run is unresponsive! So if you want to see whether your script runs automatically, you need to look at the log file under / var/spool/mail/, as shown in the figure.

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: 214

*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

Servers

Wechat

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

12
Report