How to prepare points regularly for MYSQL under linux
This article mainly introduces "how to prepare points regularly for MYSQL under linux". In daily operation, I believe that many people have doubts about how to prepare points regularly for MYSQL under linux. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "how to prepare points regularly under linux". Next, please follow the editor to study!
Write a MYSQL backup according to the request of a friend.
1. Make a shell file
two。 Modify / etc/crontab to customize the task plan
[@ more@]
Shell file:
DB_NAME='tdc_ntt_debug'
USER='root'
PWD='rootroot'
TIME=$ (date +% Y%m%d)
DEL_TIME=$ (date-- date= "7 days ago" +% Y%m%d)
DB_BAK_NAME=tdc_debug$ {TIME} .sql
DB_DEL_NAME=tdc_debug$ {DEL_TIME} .sql
BACKUP_PATH='/home/zhaoqun/DB_BAK/day_bak/'
Echo $BACKUP_PATH$DB_BAK_NAME
If test-f $BACKUP_PATH$DB_DEL_NAME
Then
Echo "Delete history dump file"
Rm-f $BACKUP_PATH$DB_DEL_NAME
Fi
Mysqldump-u $USER-p$PWD $DB_NAME > $BACKUP_PATH$DB_BAK_NAME
/ appended in etc/crontab
01 16 * root / home/zhaoqun/DB_BAK/day_bak/day_bak.sh
Make a MYSQL backup at 16:01 every day and keep a 7-day backup resume.
At this point, the study of "how to prepare points regularly for MYSQL under linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!