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

How mysqldump backs up scripts

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail how to back up the script in mysqldump. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

Mysql_full_backup.sh

#! / bin/sh

# Created by Clark 201710131716

Source / data/mysqldata/scripts/mysql_env.ini

DATA_PATH=/data/mysqldata/backup/mysql_full

DATA_FILE=$ {DATA_PATH} / dbfullbak_ `date +% F`.sql.gz

LOG_FILE=$ {DATA_PATH} / dbfullbak_ `date +% F`.log

MYSQL_PATH=/usr/local/mysql/bin

MYSQL_DUMP= "${MYSQL_PATH} / mysqldump-u ${MYSQL_USER}-p$ {MYSQL_PASS}-S / data/mysqldata/$ {HOST_PORT} / mysql.sock-A-R-x-- default-ch

Aracter-set=utf8 "

Echo > $LOG_FILE

Echo-e "= Jobs started at `date +% F'% T''% w` =\ n" > > $LOG_FILE

${MYSQL_DUMP} | gzip > $DATA_FILE

Echo-e "* * Excuted finshed at `date +% F'% T''% w` =" > > $LOG_FILE

Echo-e "* Backup file size: `du-sh ${DATA_FILE} `=\ n" > > $LOG_FILE

Echo-e "- Find expired backup and delete those files -" > > ${LOG_FILE}

For tfile in $(/ bin/find $DATA_PATH/-mtime + 6)

Do

If [- d $tfile]; then

Rmdir $tfile

Elif [- f $tfile]; then

Rm-f $tfile

Fi

Echo-e "- Delete file:$tfile -" > > ${LOG_FILE}

Done

Echo-e "\ nthanks thanks = Jobs ends at `date +% F'% T''% w` =\ n" > > $LOG_FILE

This is the end of the article on "how to back up the script for mysqldump". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

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

Database

Wechat

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

12
Report