首页 > 代码库 > 【mysqldump备份指定数据库表】my_dump.sh
【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
【mysqldump备份指定数据库表】my_dump.sh
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。