红联Linux门户
Linux帮助

LINUX下通过FTP来备份MYSQL数据

发布时间:2006-07-24 10:39:03来源:红联作者:bear10214
LINUX下通过FTP来备份MYSQL数据
出处:网侠
以下代码介绍了如何通过Linux下的FTP来备份Mysql数据库的数据。
#!/bin/bash############### Mysql Backup & FTP #################1. mkdir /home/mysqlbackup#2. chmod 700 MysqlDatebackup.sh#3. vi /etc/crontab , 30 03 * * * root /home/mysqlbackup/MysqlDatebackup.sh#everyday 03:30 the MysqlDatebackup.sh will work#System Setuphost=202.100.222.2 #ftp hostUserName=test #ftp user namePasswd=test #fto user passwordfunction Iint(){backup_path=/home/mysqlbackup #set saved backup pathfile=$path-mysql-$(date +%Y-%m-%d).tar.gzbackupCWD=/usr/local/mysql/data/$path #set backup file,the mysql pathtar -czf $backup_path/$file $backupCWD#file tarcd $backup_path#file ftpftp -i -n </dev/null 2>&1path=database1 #datebase1Iintpath=datebase2 #datebase2Iint/etc/init.d/mysqld start >/dev/null 2>&1rm -rf $backup_path/*.tar.gzecho "ftp back ok!"
文章评论

共有 0 条评论