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 every day under Linux

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces the relevant knowledge of "how to set up an automatic backup Oracle database every day under Linux". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

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_profileexport 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 file 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。 Use the crontab command of Linux to set up a scheduled task 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 file under / home/nnc_db executed at 00:00 every day, that is, the file created in step 2, needs to be adjusted according to its own backup time and file directory.

Then restart the crond service

Service crond restart IV. 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.

This is the end of the content of "how to set up automatic backup of Oracle database every day under Linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Development

Wechat

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

12
Report