In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Write MySQL backup script according to requirement, requirement is as follows: Make daily backup to specified database and save backup files for one week, delete files after one week automatically.
1. Create shell scripts
[root@server18 mysql]$ mkdir -p /home/mysql/DB_BAK/day_bak/
[root@server18 mysql]$ vim day_bak.sh
DB_NAME='tdc_ntt_debug'
USER='mysql'
PWD='mysql'
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/mysql/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
2./etc/crontab
[root@server18 ~]# crontab -e
30 21 * * * root /home/mysql/DB_BAK/day_bak/day_bak.sh
MySQL backups are made every night at 21:30 and the backup files are retained for 7 days.
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.