欢迎各位兄弟 发布技术文章
这里的技术是共享的
#!/bin/bash
#print the directory and file
backup_mysql="/home/backup/mysql/"
for file in /home/wddata/mysql_data/*
do
# performance_schema 会报错 ,排除掉这个数据库,这是自带的数据库,反正没用
if [ -d "$file" -a ${file##*/} != "performance_schema" ]
then
backup_mysqlname="${file##*/}`date '+%Y-%m-%d'`.sql";
# echo $file
# echo "/www/wdlinux/mysql/bin/mysqldump -u root -p\^\_e\)- ${file##*/} > $backup_mysql$backup_mysqlname"
/www/wdlinux/mysql/bin/mysqldump -u root -p\^\_e\)- ${file##*/} > $backup_mysql$backup_mysqlname
fi
done
仅仅备份 某一个表 ,比如 static_htmls,当然首先要保证/home/backup/mysql/static_htmls 目录存在
#!/bin/bash
#print the directory and file
backup_mysql="/home/backup/mysql/static_htmls/"
for file in /home/wddata/mysql_data/*
do
# performance_schema 会报错 ,排除掉这个数据库,这是自带的数据库,反正没用
if [ -d "$file" -a ${file##*/} != "performance_schema" ]
then
backup_mysqlname="${file##*/}_static_htmls_`date '+%Y-%m-%d'`.sql";
# echo $file
# echo "/www/wdlinux/mysql/bin/mysqldump -u root -p\^\&w_de\)- ${file##*/} > $backup_mysql$backup_mysqlname"
/www/wdlinux/mysql/bin/mysqldump -u root -p\^\&w_de\)- ${file##*/} static_htmls > $backup_mysql$backup_mysqlname
fi
done