循环备份mysql
#!/bin/bash
bei(){
da=`date +%F`
read -ep "输入指定要备份的数据库名称" file
mkdir -p /opt/$da
mysqldump -B $file > /opt/$da/$file.sql 
if [ $? -eq 0 ]; then
echo "备份成功" >> /opt/$da/log.txt
else
echo "备份失败" >> /opt/$da/log.txt
fi
}
while :
do
 bei
 read -ep "输入y继续" q
 if [ $q == "y" ]; then
   echo "继续"
  else
    break
 fi
done
 
                    
                     
                    
                 
                    
                 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号