#!/bin/bash
cd /opt/db_backup
nowTime=date +%j-%Y%m%d-%H%M%S

mysqldump -h "mysql.rds.aliyuncs.com" -udb_kb_prod_r02 -p dbname > $nowTime.sql
xz -9 $nowTime.sql

find ./ -mtime +10 -name "*.sql.xz" -type f -exec rm -rf {} ;