#!/bin/bash
pdate=`date +%F-%H`
user_name=root
host_name=localhost
db_name=typecho
db_pass=asdqwe123
prefix=wz
 db_biao=typecho_contents
##备份库##
quanku() {
mysqldump -u$user_name  -p$db_pass -P3306  $db_name > /data/backup/${pdate}.sql
tar czf /data/backup/${prefix}${pdate}.sql.tgz /data/backup/${pdate}.sql &> /dev/null
}

##备份表##
biao() {
mysqldump -u $user_name  -p $db_pass -P3306  $db_name $db_biao > /data/backup/${db_biao}${pdate.sql}
tar czf /data/backup/${prefix}${pdate}.sql.tgz /data/backup/${db_biao}${pdate.sql} &> /dev/null
}
$1

 加入计划任务 vim  /etc/crontab
 */60 * * * * root sh /root/shell/mysql.sh quanku

/30 * root sh /root/shell/mysql.sh biao
重启
systemctl restart crond