💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
``` #!/bin/sh # 数据库认证 user="***" password="*******" host="localhost" db_name="****" port="3306" # 备份路径 bak_path=/data/sql_bak/$db_name #保存备份个数 number=3 if [ -d $bak_path ];then echo $bak_path exsits else echo "mkdir $bak_path" mkdir -p $bak_path fi # Dump数据库到SQL文件 mysqldump -u$user -p$password -h $host -x $db_name > $bak_path/$(date -I).sql #写创建备份日志 echo "create $bak_path/$(date -I).sql" >> $bak_path/log.txt #找出需要删除的备份 delfile=`ls -l -crt $bak_path/*.sql | awk '{print $9 }' | head -1` #判断现在的备份数量是否大于$number count=`ls -l -crt $bak_path/*.sql | awk '{print $9 }' | wc -l` if [ $count -gt $number ];then rm $delfile #写删除文件日志 echo "delete $delfile" >> $bak_path/log.txt fi ```