Using command line FTP on Linux or windows and executing it automatically on a regular basis is a very practical function that can improve work efficiency.
Linux:Use an execution script auto_ftp.sh :#! /Bin/sh
Cd/home/user1/
Ftp-I-n <FTPIT
Open 10.1.9.201 21
User username password
Cd bakdir
Bin
Prompt
Mget *. BAK
Bye
Quit
FTPIT
Exit
You can modify the Italic content based on the actual situation.
Note:
1. If there are shell special characters such as @, #, $, and % in username and password, escape them before the character, for example, 123 @ 346 $ as 123 @ 346 $.
2. prompt starts a switch function to control interaction prompts. If FTP is set to Interactive mode off, do not write prompt; otherwise, add prompt.
The following is an example of the get backup file script get_bak.sh:
#! /Bin/sh
CD/home/user1/
# Rename the old backup file first
For I in $ (find.-Name "DB _ *. Bak"); Do MV $ I. Old; done
# Determine whether auto_ftp.sh is successfully executed
If./auto_ftp.sh 2>/dev/null
Then
# Determine whether the latest backup file is a 0-byte empty file
If [[-s dB _ 'date + % Y % m % d '0400. Bak]
Then
# Echo "not 0"
# A valid backup file is successfully obtained. Delete the old backup file,
RM *. Old
Fi
Fi
Windows:Run the following command:
FTP-n-s: "G:/dbbak/1.ftp"
1. ftp is an ftp command control file in the following format:
Open 10.1.9.201 21
User Username Password
Bin
Prompt
Mput *. dmp
Mput *. SQL
Mput *. bat
Bye
Quit
Exit