#! /bin/sh
day_str=`date +%j`
day=`date +%Y%m%d`
days_str=`echo "$day_str % 60"|bc`
cd /home/db_backup
echo ${day}
mysqldump --opt -hhostip -uusername -ppassword --databases dbname1 dbname2 > ${day}.sql
gzip -f ${day}.sql
#
#backup binary file
mysqladmin -hhostip -uusername -ppassword flush-logs
cp /var/lib/mysql/mysql-bin* .
gzip -f mysql-bin*
如果电脑上没有bc或者mysqladmin,需要安装 yum -y install mysql bc即可
时间: 2024-10-07 21:00:53