shell脚本,mysql数据库的备份,并压缩
db_user="root"
db_passwd="xxx"
db_host="localhost"
databases="xxx-prod"
backup_dir="/backup/mysql_backup"
backip_test="/home/ttx/app/mysql_backup/today"
time="$(date +"%Y-%m-%d")"
test ! -w $backup_dir && echo "Error: $backup_dir is un-writeable." && exit 0
test ! -d "$backup_dir" && mkdir "$backup_dir"
for db in $databases
do
mv /backup/mysql_backup/wms_backup.gz /backup/mysql_backup/$db.$time.gz
mysqldump -h $db_host $db | gzip -9 > "$backup_dir/wms_backup.gz"
done
find $backup_dir -name "*.gz" -mtime +7 |xargs rm -rf
exit 0;
惜秦皇汉武,略输文采;唐宗宋祖,稍逊风骚。
一代天骄,成吉思汗,只识弯弓射大雕。
俱往矣,数风流人物,还看今朝