This paper mainly solves the problem of how to use the lftp command to backup files to FTP server in Linux Debian system.
Conditions:
1, Linux DEBIAN6 system, network connectivity is good.
2,/etc/apt/sources.list inside the URL is correct.
3, the FTP server's account and password is correct.
Thought:
1. The operation of the backup file is performed by a script.
2, in the Linux system under the regular execution of the script.
Content:
Step one: Learn how to execute scripts regularly under Linux systems
Method One, edit with crontab command
A. Crontab-u//Setting up a user's Cron service, which is normally required by the root user when executing this command
CRONTAB-L//list details of a user's cron service
Crontab-r//Remove cron service for no users
CRONTAB-E//Edit a user's cron service
B. When editing a cron service, there are some formatting and conventions for editing the content, input: Crontab-u root-e
C. Enter vi edit mode, the content of edit must conform to the following format: */1 * * * * * command
D. There are several special symbols in addition to the numbers: "*", "/" and "-", ",", * represents all the values within the range of the number, "/" for each meaning, "*/5" means every 5 units, "-" representing from a number to a number, "," separate several discrete numbers.
E. Examples:
Every morning at 6.
0 6 * * * echo "goodmorning."
Every two hours
0 */2 * * * echo "Have abreak now." >>/tmp/test.txt
Method Two, edit/etc/crontab
A. Shell=/bin/bash
Path=/sbin:/bin:/usr/sbin:/usr/bin
Mailto=root//If there is an error, or if there is data output, the data is sent to this account as mail
home=///user Run path, this is the root directory
B. Add a Timer + command to the end of a line such as method one
Step two: script to write backup files
1, compressed files through the zip command
A, Apt-get install ZIP//installation zip software
b, zip–r compressed file name. zip file File
2, through the LFTP landing FTP server
A, Apt-get install lftp//download lftp software
B, Lftp Ftp://user:passwd@ip:port
lftp ftp://User: Password @ip address: port number
3. Upload files via mput command
Mput need to upload the filename
4, the overall script example
1 #!/bin/bash
2
3 Mysqldump-uroot-pdebianc2013_database >/root/c2013_database.sql
This is the export database file
4 Zip-r Backup.zip/home/data/root/c2013_database.sql
Compress files
5
6 Lftp ftp://heqiunong:heqiunong@172.16.232.37:21 <<eof
Landing FTP
7 Mput/root/backup.zip
Execute upload command
8 EOF
Exit
9
Ten RM C2013_database.sql
Delete intermediate files
One RM backup.zip
Step three, combine the first and second steps