BAT code to back up files and upload them to an FTP server _dos/bat

Source: Internet
Author: User
Tags rar

Timed backup files and FTP upload to backup server

Copy Code code as follows:

@echo off
Color 0f
Title scheduled backup file and FTP upload to backup server

Rem folder to back up
Echo
set/p bak_webfile= Please drag the file (folder) you want to upload here =

REM Current date (format YYYYMMDD)
Set bak_date=%date:~0,4%%date:~5,2%%date:~8,2%

REM FTP information
Set bak_ftpserver=202.96.189.52
Set bak_ftpusername=wingl83
Set Bak_ftpuserpass=l7l2o6oo

Echo
Echo
Echo: Start uploading

REM generates FTP command files
Echo Open%bak_ftpserver% >ftp.up
Echo%bak_ftpusername%>>ftp.up
Echo%bak_ftpuserpass%>>ftp.up
Echo Bin >>ftp.up
echo mput%bak_webfile%\* >>ftp.up
echo Bye >>ftp.up

Ftp-s:ftp.up-i >>%bak_logpath%log-%bak_date%.txt
Del ftp.up/q
Del log-%bak_date%.txt/q

Echo
Echo
Echo: Upload complete

Timed backup files and FTP upload to backup server

Copy Code code as follows:

REM timed backup file and FTP upload to backup server
Rem folder to back up
Set bak_webfile=f:\ backup \
REM Temp Folder
Set Bak_tmpfile=c:\~uptemp\
REM Log Folder
Set bak_logpath=c:\~bak_log\
REM-generated RAR filename
Set BAK_BAKFILE=YYYYMMDD (page backup)
REM Current date (format YYYYMMDD)
Set bak_date=%date:~0,4%%date:~5,2%%date:~8,2%

REM FTP information
Set bak_ftpserver=202.96.189.52
Set bak_ftpusername=wingl83
Set Bak_ftpuserpass=l7l2o6oo

Set bak_timestart=%time%
MD%bak_tmpfile%
MD%bak_logpath%

echo--------begin compression [%bak_timestart%] >%bak_logpath%log-%bak_date%.txt

"C:\Program files\winrar\rar.exe" a-ag+%bak_bakfile%%bak_tmpfile%%bak_webfile%

echo--------compression complete, start uploading [%time%/%bak_timestart%] >>%bak_logpath%log-%bak_date%.txt

REM generates FTP command files
Echo Open%bak_ftpserver% >ftp.up
Echo%bak_ftpusername%>>ftp.up
Echo%bak_ftpuserpass%>>ftp.up
Echo Bin >>ftp.up
echo mkdir%bak_date% >>ftp.up
echo CD%bak_date% >>ftp.up
echo mput%bak_tmpfile%\* >>ftp.up
echo Bye >>ftp.up

Ftp-s:ftp.up-i >>%bak_logpath%log-%bak_date%.txt
Del ftp.up/q
REM Xcopy%bak_tmpfile%* c:\temp/y
Del%bak_tmpfile%*.*/q/s
RD%bak_tmpfile%/Q
echo--------upload complete [%time%/%bak_timestart%] >>%bak_logpath%log-%bak_date%.txt

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.