[Mysql] ftp automatically uploads mysql backup files
In the previous article, mysql daily backup shell script provided the script to back up data to the local device using mysqldump. The following is the script to transmit the backup file to the remote server using ftp. Of course, scp and rsync can also be used.
#! /Bin/sh ############################# orangleliu # upload a specified file through ftp # centos usage (date formatting on mac is not very easy) # note that ftp must be switched to the binary mode ############################# uploaded the server sets HOST = 'ftp .wificdn.com 'USER = 'ddd' PASSWD = 'er # backp.2 '# name of the file to be uploaded and deleted, retain for 10 days BASE_DIR = "/home/backup" BACKUP_LOG = "$ {base_dir}/mysql_backup.log" DBNAME = "radius" FILE_UPLOAD = "$ {DBNAME}-$ (date +" % y-% m-% d "2.16. SQL .gz" FILE_DELE = "$ {DBNAME}-$ (date-d"-10 day "+" % Y-% m-% d "2.16. SQL .gz "echo" ftp upload $ FILE_UPLOAD finished at $ (date + '% Y-% m-% d % H: % M: % s') ">" $ BACKUP_LOG "ftp-n $ HOST <
Important Notes:
The environment used here is that centosftp must be switched to binary mode.