This article takes Centos7.6 system and Oracle11g as an example: 1. Find the database environment variables first If you are in the root account, you must first log in to the account where the database is located su oracle cat ~/.bash_profile export PATH export ORACLE_BASE=/home/nnc_db/app export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1 export PATH=$PATH:$ORACLE_HOME/bin export ORACLE_SID=orcl The environment variable has been found! 2. Edit the backup script file First copy and paste the environment variables into the bak.sh file, Then define a variable date (its function is to name the daily backup file for easy identification), and use the expdp command to export the database. The code is 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. 3. Use Linux crontab command to set up scheduled tasks The function of crontab -e is to set up scheduled tasks using a text editor (the specific usage of crontab is not described here); Enter in the text editor The above code means that the bak.sh file in Then restart the crond service 4. Test whether the task runs successfully According to the information I collected online, some friends said that crontab -e will not take effect three minutes after being set successfully! That is to say, if you set a task at 10:00 am and want to test whether it is successful, you may set the next scheduled task to 10:02, there may be problems! But here I use Set it to run once every minute and found no problems. Another big pitfall for novices is that if you run the script file directly, the detailed process will be output on the command line, but there will be no response when you set a scheduled task to run! So if you want to see whether your script is running automatically, you need to look at the log file in Summarize The above is the method that I introduced to you to set up automatic daily database backup under Linux. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: Implementation of element multiple form validation
>>: How to set mysql5.7 encoding set to utf8mb4
Table of contents Basic application of javascript...
Preface I believe everyone knows that indexes are...
Table of contents Overview Solution 1: Closures S...
This article shares the specific code of jQuery t...
As shown below: XML/HTML CodeCopy content to clip...
MySQL 8.0.22 installation and configuration metho...
Today I used a virtual machine to do an experimen...
When configuring the interface domain name, each ...
This article describes how to install and configu...
This article shares the specific code for JavaScr...
This article shares the specific code of the vue3...
1. Command Introduction The read command is a bui...
Table of contents Case scenario Solving the probl...
In the front-end and back-end separation developm...
This article shares the installation and configur...