In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to implement the automatic backup process on MySQL CentOS. I hope I can add and update some knowledge to you. If you have any other questions you need to know, you can continue to follow my updated articles in industry information.
In development, we often use Svn or Git to manage our code or project-related files, but they all have one thing in common: version control.
Many people will ask why you want to use Svn or Git, then I will ask: I believe the code you wrote is very good, but one day you modified a lot of Bug, but suddenly realized that there was a more important algorithm in the previous code that you accidentally overwritten, what should you do then?
Recommend "mysql Video tutorial"
Maybe you will tell me that you can back up the currently modified file or the current project before modifying the code.
But how many backup files will there be on your machine over time?
If one day your colleague needs to roll back to the previous code to see the reason for Bug at that time, will you find the file at a specified time on your machine and send it to him?
Of course not, we have Svn or Git, we can easily see the previous version of the file, but also easy to compare. So now it is clear that versioning is important.
The same is true of databases. 99% of our systems are inseparable from databases, because we always store data.
What if our database is mistakenly deleted, hacked or maliciously modified?
Then we can try to let our cloud server automatically help us back up the data of the database to the designated location, in case one day our database accidentally trembles, we can also use the backup database script to restore directly.
Script on:
# db usernamedb_user= "test" # db passworddb_passwd= "test" # db hostdb_host= "121.201.5.216" # backup db namedb_name= "Alterem" # the directory for story your backup file. Backup_dir= "backup" cd # date format for backup file (dd-mm-yyyy) time= "$(date +"% Y-%m-%d-%H-%M-%S ")" # mysql Mysqldump and some other bin's path MYSQL= "/ usr/local/mysql/bin/mysql" MYSQLDUMP= "/ usr/local/mysql/bin/mysqldump" GZIP= "/ bin/gzip" $MYSQLDUMP-u $db_user-h $db_host-p$db_passwd $db_name | $GZIP-9 > "/ data/backup/$backup_dir/$db_name" _ "$time.gz"
Create a timer
Crontab-e
Add timer
# data backup 301 * / root/mysql-backup.sh at 01:30 every morning
Restart the timer
/ etc/rc.d/init.d/crond restart
Cron parsing
# For details see man 4 crontabs# Example of job definition:#.-minute (0-59) # |.-hour (0-23) # | |.-day of month (1-31) # |.-month (1-12) OR jan,feb,mar Apr... # |.-day of week (0-6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat# | | # * user-name command to be executed copy code
These are the details of MySQL performing automatic backups on CentOS. Please follow other related articles for more information.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.