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

Sample mysqldump database backup

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

[root@localhost mdata] # cat mysqlbacks backup.shallows backups Dir = `date +% F` [- d $BACKUP_DIR/$DATE_DIR] | | mkdir $BACKUP_DIR/$DATE_DIR-p & > / dev/nulltime= "$(date +"% Y-%m-%d ")" USER=PASS=PORT= # backup the database, full backup of DB_LIST=$ (/ mdata/mysql/bin/mysql-u$USER-p$PASS-P$PORT-s-e "show databases) "2 > / dev/null | egrep-v" Database | information_schema | mysql | performance_schema | sys ") for DB in $DB_LIST; do if! / mdata/mysql/bin/mysqldump-u$USER-p$PASS $DB > $BACKUP_DIR/$DATE_DIR/$DB-$ {time} .SQL 2 > / dev/null Then echo "$DATE_DIR $DB-$ {time} .sql backup failed" > / mdata/mysql/mysqlbackup.log fidone # delete backup DEL_DIR= `date-d "- 2 days" +% F` [- d $BACKUP_DIR/$DEL_DIR] & & rm-rf $BACKUP_DIR/$DEL_DIR# join the scheduled task (echo "1 01 * / mdata/mysql/mysql_backup.sh"; crontab-l) | crontab

Note: this is a binary installation, and the installation directory can also be changed to a variable for reference only.

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

Servers

Wechat

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

12
Report