Implement ftp automatic backup shell script in linux

Source: Internet
Author: User

Use the here document Copy codeThe Code is as follows :#! /Bin/sh
Ftp-ivn 210.29.28.124 <EOF
User yun yun2011
LCD/home/veyun
Cd/home/veyun/yhb
Get v
Bye
EOF

Explanation:

-I: Disable interaction prompts during multi-file transmission, so there will be no prompts for users to enter their usernames and passwords.
-N: Automatic Logon during initial connection is blocked.
-V: Set the ftp command to verbose mode, so that you can see the command in the session

In this example, log on with the username yun and password yun2011.

The following is a simple shell script written by myself.

Purpose: download the file from remotedir to the localdir directory, and list all the remotedir file names to the dirlist file,

Finally, package the downloaded file and delete the downloaded file (based on the file name in dirlist ).

Script explanation:
2-8: define variables
9-16: ftp download
18-20: Packaging
22: get the file name in the dirlist File
23-26: get the file names one by one and delete the corresponding files.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.