说明:
1、定时备份mysql的表sql语句,并且保留30天文件夹,会定期删除30天前的文件夹
2、根据业务场景需要,需要定时将表数据导出sql语句
3、定时将sql语句推送到另外指定的数据库中
4、编写shell脚本是实现批量导入mysql的sql语句
一、Shell脚本备份mysql表数语句
# !/bin/bash# 定义变量
db_host="172.16.1.9"
db_port=3306
db_user="root"
db_passwd="Mysql234"
db_name="halobike12"
db_path="/data/script"
db_date=`date '+%Y%m%d%H%M'`
db_time=`date '+%Y-%m-%d'`
baol_num=30# 备份表
db_table=(biz_bike_warehouse biz_monitor_point_ai_bike biz_operation_vehicle biz_pile_infobiz_unreported_vehicle biz_unreported_vehicle_bike report_history site_real_num)mk_data(){if [ ! -d ${db_path} ];thenecho "创建文件夹中..."mkdir -p ${db_path}elseecho "该文件夹已存在"fi
}> ${db_path}/check.txtdb_backsql(){for table_name in