使用shell+mysqldump批量备份数据库
echo "#####数据备份流程#####" ls_date=` date +%Y%m%d` sql=(information_schema accountdb adu asr auth authdb2 cameradb cceu cfsu ctu data_analysis dps dsu ecmu edmu emap ewu filestoragedb imu mcu mcuapi mediadb mysql nextdb2 open_falcon performance_schema permission phoenix_alarm phoenix_api_db phoenix_inspect phoenix_machine phoenix_service poc psib ptu pwitch ras resourceService ruleenginedb rvsl sfu sls storagedb switch sys udu voip) for i in "${!sql[@]}"; do echo ${sql[$i]} mysqldump -u用户名 -p密码 ${sql[$i]}>/mysqlbak/${sql[$i]}${ls_date} #备份路径 done echo "#####过期数据清理#####" find /mysqlbak -mtime +180 -name ".sql" -exec rm -rf {} ;
sql数组值为需要备份的数据库名