LINUX下通过FTP来备份MYSQL数据
类别: LINUX教程
#!/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 Setup
host=202.100.222.2 #ftp host
UserName=test #ftp user name
Passwd=test #fto user password
function Iint()
{
backup_path=/home/mysqlbackup #set saved backup path
file=$path-mysql-$(date +%Y-%m-%d).tar.gz
backupCWD=/usr/local/mysql/data/$path #set backup file,the mysql path
tar -czf $backup_path/$file $backupCWD
#file tar
cd $backup_path
#file ftp
ftp -i -n <<!
open $host
user $UserName $Passwd
if [ ! [ -d WEB-BACK/$path ]]; then
mkdir MYSQL-BACK/$path
fi
cd MYSQL-BACK/$path
put $file
bye
!
}
/etc/init.d/mysqld stop >/dev/null 2>&1
path=database1 #datebase1
Iint
path=datebase2 #datebase2
Iint
/etc/init.d/mysqld start >/dev/null 2>&1
rm -rf $backup_path/*.tar.gz
echo "ftp back ok!"
############### 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 Setup
host=202.100.222.2 #ftp host
UserName=test #ftp user name
Passwd=test #fto user password
function Iint()
{
backup_path=/home/mysqlbackup #set saved backup path
file=$path-mysql-$(date +%Y-%m-%d).tar.gz
backupCWD=/usr/local/mysql/data/$path #set backup file,the mysql path
tar -czf $backup_path/$file $backupCWD
#file tar
cd $backup_path
#file ftp
ftp -i -n <<!
open $host
user $UserName $Passwd
if [ ! [ -d WEB-BACK/$path ]]; then
mkdir MYSQL-BACK/$path
fi
cd MYSQL-BACK/$path
put $file
bye
!
}
/etc/init.d/mysqld stop >/dev/null 2>&1
path=database1 #datebase1
Iint
path=datebase2 #datebase2
Iint
/etc/init.d/mysqld start >/dev/null 2>&1
rm -rf $backup_path/*.tar.gz
echo "ftp back ok!"
- 上一篇: LINUX启动全线提速法
- 下一篇: 必须学会的几个常用网络测试命令
-= 资 源 教 程 =-
文 章 搜 索