Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4823353
  • 博文数量: 930
  • 博客积分: 12070
  • 博客等级: 上将
  • 技术积分: 11448
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-15 16:57
文章分类

全部博文(930)

文章存档

2011年(60)

2010年(220)

2009年(371)

2008年(279)

分类: Mysql/postgreSQL

2010-04-16 12:25:32

#!/bin/bash
dateDIR=`date +"%y-%m-%d"`
mkdir -p /bak/databases/$dateDIR
user=root
password=123456
for i in `/usr/local/mysql/bin/mysql -u$user -p$password -e "show databases" | grep -v "Database"`
do
  /usr/local/mysql/bin/mysqlhotcopy -u $user -p $password $i /bak/databases/$dateDIR
done

如果mysqlhotcopy运行报错,如下:

Can't locate DBI.pm in @INC (@INC contains: /usr/local/apache2/ixiubao/extman/libs /usr/local/lib/perl5/5.8.8/i686-linux /usr/local/lib/perl5/5.8.8 /usr/local/lib/perl5/site_perl/5.8.8/i686-linux /usr/local/lib/perl5/site_perl/5.8.8 /usr/local/lib/perl5/site_perl .) at /usr/local/apache2/ixiubao/extman/libs/Ext/Mgr/MySQL.pm line 13. BEGIN failed--compilation aborted at /usr/local/apache2/ixiubao/extman/libs/Ext/Mgr/MySQL.pm line 13. Compilation failed in require at /usr/local/apache2/ixiubao/extman/libs/Ext/Mgr.pm line 37.

需要安装:
perl-DBD-MySQL-3.0007-1.fc6.i386.rpm
perl-DBI-1.52-1.fc6.i386.rpm
perl-DBD-Pg-1.49-1.fc6.i386.rpm
(以上rpm包,在红帽5光盘上可以找到)

#!/bin/bash
cd /backup
dateDIR=`date +"%y-%m-%d"`
mkdir -p $dateDIR/data
\cp -r /usr/local/apache/htdocs /backup/$dateDIR/
for i in `/usr/local/mysql/bin/mysql -uroot -p123456 -e "show databases" | grep -v "Database"`
do
  /usr/local/mysql/bin/mysqldump -uroot -p123456 --default-character-set=gbk --opt $i | gzip > /backup/$dateDIR/data/${i}_${dateDIR}
.sql.gz
done

阅读(700) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~