【mysqldump备份指定数据库表】my_dump.sh
【mysqldump备份指定数据库表】my_dump.sh
#!/bin/bash # # 2014/12/12 function dump_db_table() { local d_db_base=‘/data/svr/mysql‘ local s_datetime=$(date +%Y%m%d_%H%M%S) local s_port=3306 local s_password=‘xxx‘ local s_db=$1 if [ -z ${s_port} ]; then echo "Usage: $0 database table" exit 2; fi local s_table=$2 local d_backup="/home/backup/mysql/${s_port}/mysqldump/${s_db}" if [ -z ${s_table} ]; then local dump_args="${d_db_base}/bin/mysqldump -h 127.0.0.1 -P ${s_port} -u root --password=${s_password} -B ${s_db}" local f_dump_tar="${d_backup}/${s_datetime}-${s_db}.gz" else local dump_args="${d_db_base}/bin/mysqldump -h 127.0.0.1 -P ${s_port} -u root --password=${s_password} ${s_db} ${s_table}" local f_dump_tar="${d_backup}/${s_datetime}-${s_table}.gz" fi test -d ${d_backup} || mkdir -p ${d_backup} echo "[+] `date` Port: ${s_port} DB: ${s_db}.${s_table}" #${d_db_base}/bin/mysqldump -h 127.0.0.1 -P ${s_port} -u root --password=${s_password} ${s_db} ${s_table} |gzip >${f_backup_db_compressed} ${dump_args} |gzip >${f_dump_tar} #echo "${dump_args}" echo "[-] `date` Saved to: ${f_dump_tar}" echo "[-] `date` Done." echo sleep 1s } dump_db_table d_abc t_abc dump_db_table d_def t_def
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。