Use WinRAR and FTP commands to automatically back up files and automatically upload to the specified FTP server _dos/bat

Source: Internet
Author: User
Tags ftp commands rar

1. The use of WinRAR to build a compressed package

First, the file path to be backed up is collected in a text file, as in my rat.txt, the contents are as follows:

"C:\Documents and settings\evanzhang\desktop\untitled." JPG "
"C:\Documents and Settings\evanzhang\desktop\ stationery collar confirmation form. xls"
"C:\Documents and Settings\evanzhang\desktop\test.exe"

Create Backup.bat files, as follows

"C:\Program Files\winrar\winrar.exe" a-m5-k-t-ag[yyyy-mm-dd-hh-mm-ss] C:\backup-.rar @c:\rar.txt
-A add files to the compressed file
-M5 Set Compression ratio
-K Locking compressed file does not allow editing
-T post-compression test
-ag generate file name with current date
C:\backup-rar to generate a compressed packet prefix
@c:\rar.txt files to compress

2. Set up FTP command batch processing

Add the following line to Backup.bat
Ftp-s:c:\ftp.txt
Set up, ftp.txt content as follows
Open ***.***.***.***
User
Password
Bin
Put Back*.rar
Bye

Open host name such as Open
User FTP username
Password FTP account password
Bin is delivered in 2
Put Back*.rar is to upload the file that you just compressed with rar
Bye for End FTP dialog
3. Specify the elapsed time in the Windows work plan Backup.bat
4. Test
The complete contents of Backup.bat are as follows:
"C:\Program Files\winrar\winrar.exe" a-m5-k-t-ag[yyyy-mm-dd-hh-mm-ss] C:\backup.rar @c:\rar.txt
Ftp-s:c:\ftp.txt

The complete contents of Rar.txt are as follows:

"C:\Documents and settings\evanzhang\desktop\untitled." JPG "
"C:\Documents and Settings\evanzhang\desktop\ stationery collar confirmation form. xls"
"C:\Documents and Settings\evanzhang\desktop\test.exe"

The complete contents are as follows:

Open ***.***.***.***
User
Password
Bin
Put Back*.rar
Bye


Run the test and the results are as follows:

Ftp> Connected to **.**.**.**
Open **.**.**.**
Serv-u FTP Server v6.3 for WinSock ready ...
User (**.**.**.** (none)):
331 User name Okay, need password.

230 User logged in, proceed.
Ftp> bin
Type set to I.
Ftp> put Back*.rar
PORT Command successful.
Opening BINARY mode data connection for Backup[2006-09-14-13-30-06].rar.
Transfer complete.
ftp:747412 Bytes sent in 11.94Seconds 62.61kbytes/sec.

Ftp> bye
221 goodbye!

Because winrar compression really graphics interface compression, so do not see the compression record, if it is under the Linux use of tar compression, compression records will see very clearly.

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.