1. Add backupmysqleveryday.sh (vi/data/shell/backupmysqleveryday.sh)
#!/bin/sh
#this Shell is the user for backup MySQL data everyday
#author: www.ieliwb.com
#path-config
base_mysql_path=/data/webserver/mysql/
mysql_dump_path=/data/mysqlbackup/
mnt_back_path=/mnt/web/mysqlbackup/
ftp_back_path=mysql_data_backup/
#mysql-config
Mysql_user= "Root"
Mysql_pass= "*******"
#ftp-config
ftp_host= "IP"
Ftp_user= "********"
Ftp_pass= "********"
Backup_name= ' Date +%y%m%d%h%m%s '
CD ${mysql_dump_path}
#mysqldump
${base_mysql_path}bin/mysqldump-u${mysql_user}-p${mysql_pass}-all-database > ${backup_name}.sql
#pack
Tar zcf ${backup_name}.tar.gz ${backup_name}.sql
Rm-f ${backup_name}.sql
#backup to MNT
CP ${backup_name}.tar.gz ${mnt_back_path}${backup_name}.tar.gz
#ftp to other host
ftp-n<
Open ${ftp_host}
User ${ftp_user} ${ftp_pass}
Bin
Prompt off
CD ${ftp_back_path}
Passive
Put ${backup_name}.tar.gz
Close
Bye
!
2. Add a timing plan (VI/ETC/CRONTAB)
0 * * * root/data/shell/backupmysqleveryday.sh
Daily 0:01.
MySQL timed automatic backup and FTP to remote script under Linux