The previous MySQL daily backup shell script gives a script that uses mysqldump to back up to the local, followed by a script that uses FTP to transfer the backup file to the remote server. Of course, can also use Scp,rsync and so on plan.
#!/bin/sh#############################orangleliu#ftp upload the specified file#centos Use (the formatting of dates on Mac is not very good)#注意ftp一定要切换成二进制模式#############################上传的服务器设置host=' ftp.wificdn.com 'User=' DDD 'Passwd=' ER#BACKP.2 '#上传和要删除的文件名称, reserved for 10 daysBase_dir="/home/backup"backup_log="${base_dir}/mysql_backup.log"Dbname="radius"File_upload="${dbname}-$ (date +" )%Y-%m-%d"). sql.gz"file_dele="${dbname}-$ (date-d"-TenDay" +"%Y-%m-%d"). sql.gz"Echo"ftp upload $FILE _upload finished at $ (date + '%Y-%m-%d %H :%M:%s') ">>"$BACKUP _log"Ftp-n$HOST<<end_scriptquote USER$USERQuote PASS$PASSWDBinarylcd$BASE _dirPromptmput$FILE _uploadMdelete$FILE _deleQuitend_scriptExit 0
Key issues to note:
- The environment used here is CentOS
- FTP must be switched to binary mode
Copyright NOTICE: This article is Orangleliu (http://blog.csdn.net/orangleliu/) original article, the article reproduced please declare.
[mysql]ftp automatically upload MySQL backup files