linux本地备份mysql和SCP异地备份mysql脚本
#!/bin/bash
date=KaTeX parse error: Expected group after '_' at position 151: …sql/backup/full_̲date.sql
if [ $? -eq 0 ];then
echo “数据备份完成”
scp /software/mysql/backup/full_$date.sql weblogic@10.196.12.2:/software/mysql/backup
sleep 4
echo “远程备份完成”
find /software/mysql/backup/ -name “full_*” -type f -mtime +7 -exec rm {} ;
fi
#!/bin/bash
date=$(date +%Y%m%d)
/software/mysql/bin/mysqldump -uroot -pGZ_citizen_2021 --all-databases --single-transaction --events --flush-logs > /software/mysql/backup/full_$date.sql
if [ $? -eq 0 ];then
echo "数据备份完成"
scp /software/mysql/backup/full_$date.sql weblogic@10.196.12.2:/software/mysql/backup
sleep 4
echo "远程备份完成"
find /software/mysql/backup/ -name "full_*" -type f -mtime +7 -exec rm {} \;
fi