#!/bin/bash
SQL_host=localhost
SQL_User=root
SQL_Passwd=
123456
SQL_db=
$(date +
%Y%m%d) #database name
backup_path=/data/mysqlbak
file=
$(date +
%Y%m%d).tar.gz
#mysql_path=/usr/local/mysql/bin
cd
$backup_path
if [ -d
$backup_path/
$(date +
%Y%m%d) ]
then
cd
$backup_path/
$(date +
%Y%m%d)
else mkdir
$backup_path/
$(date +
%Y%m%d)
cd
$backup_path/
$(date +
%Y%m%d)
fi
mysqldump -h
$SQL_host -u
$SQL_User -p
$SQL_Passwd --add-drop-database --add-drop-table -f test >
$SQL_db.sql --single-transation
sleep
3
tar -czf
$file $SQL_db.sql
sleep
5
#path=/backup/
data=
`date -d ' 8 day ago' +%Y%m%d`
rm -rf
$backup_path/
"$data"
转载请注明原文地址: https://ju.6miu.com/read-1294235.html