#!/bin/bash ftp -n<<!open 192.168 . 220.129 user ls TOORBINARYHASHCD /path/to/BACKUPLCD / Path/to/need/backupprompt mkdir ' date + " %y%m%d " ' CD ' Date + %y%m%d " "mput *closebye !
Open line-the host IP to be backed up to
User Line--ls is the username of the host to be backed up, toor the password for the front user
Binary lines-Transfer using binary mode
hash--each 1k size output A # number, can not
CD line-the directory to upload the backup file to
LCD line--backup files in the local directory
Prompt-----------to make the back mput upload multiple files without having to enter "yes" every time to confirm
mkdir line--In the backup host to create a backup directory by date, here is mainly to demonstrate this mode can and SSH generally use mkdir and anti-quotes
CD line-the directory to upload to the backup file
Mput--Upload all files under the Local directory folder, or write a specific file name
Close row--Closes the FTP connection
Bye line--Exit FTP
A daily backup is required, then a scheduled task can be
Reference:
http://blog.csdn.net/zzzzcs/article/details/23993165
FTP timed automatic upload file script (CentOS)