Skip to content


Linux下通过FTP来备份Mysql数据

(转自村子lts98)
http://www.phpx.com/happy/top94529.html

加上了中文注释,有问题大家一起讨论。
#!/bin/bash
host=202.100.222.2 #FTP主机
UserName=test #FTP用户名
Passwd=test #FTP密码

function Iint() #处理涵数
{
backup_path=/home/mysqlbackup #压缩文件存放的目录
file=$path-mysql-$(date +%Y-%m-%d).tar.gz #文件名
backupCWD=/usr/local/mysql/data/$path #需备份的path
tar -czf $backup_path/$file $backupCWD #执行备份操作

cd $backup_path
ftp -i -n /dev/null 2>&1 #停止Mysql服务
path=database1 #需备份的数据名
Iint #调用处理涵数
path=datebase2
Iint
/etc/init.d/mysqld start >/dev/null 2>&1 #启动Mysql服务

rm -rf $backup_path/*.tar.gz #删除压缩文件
echo “ftp back ok!”

——————————————————————————–

http://www.phpx.com/happy/top94529.html

Posted in Mysql, 备份, 技术.

Tagged with , .


No Responses (yet)

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.