1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| db_user="username"
db_passwd="password"
table1="table1" table2="table2"
backup_dir="/usr/local/backup/mysqlbackup"
time="$(date +"%Y-%m-%d %H:%M:%S")"
mysqldump -u$db_user -p$db_passwd $table1 > "$backup_dir/$table1"_"$time.sql" mysqldump -u$db_user -p$db_passwd $table2 > "$backup_dir/$table2"_"$time.sql"
find $backup_dir -name "*.sql" -mtime +30 -exec rm -rf {} \;
|