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 Advantage 1: Optimization of di...
MySQL is a commonly used open source database sof...
HTML is made up of tags and attributes, which are...
Only display Docker container mount directory inf...
Preface: In MySQL, views are probably one of the ...
MySQL 8.0 compressed package installation method,...
CentOS official website address https://www.cento...
Table of contents Hidden Problems Solution to ada...
This week has been as busy as a war. I feel like ...
1. Docker startup problem: Problem Solved: You ne...
Text carousels are very common in our daily life....
Table of contents APIs used Simple Example person...
Table of contents Preface Discover the cause Cust...
This article shares with you how to use canvas an...
View system help help contents mysql> help con...