filename=`date +%Y%m%d_%H%M%S`
database=finebw
servername=official
createfilename=${servername}_${database}_${filename}
mysqldump -uroot -pfishjoy123456 ${database}>/mnt/mysql_data_bak/${createfilename}.sql
cd /mnt/mysql_data_bak
tar -zcvf ${createfilename}.tar.gz ${createfilename}.sql
rm -rf /mnt/mysql_data_bak/${createfilename}.sql
scp -P 922 ${createfilename}.tar.gz [email protected]:/mnt/data/remote_mysql_data_bak
find /mnt/mysql_data_bak -mtime +3 -name "${database}_*" -exec rm -rf {} \;
时间: 2024-10-03 16:55:00