Get the App
SLTechnology News&Howtos  ›  Development  › 

How to backup files and upload them to bat of FTP server

Shulou Source: shulou.com Published: 2022-06-03 08:27:47 11月13日 Update

This article mainly introduces how to backup files and upload to the FTP server bat, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor with you to understand.

Back up files regularly and upload them to the backup server by FTP

The code is as follows:

@ echo off

Color 0f

Title backs up files regularly and uploads them to the backup server by FTP

Folder to be backed up by rem

Echo:

Set / p bak_webFile= Please drag the file (folder) to be uploaded 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 file

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 completed

Back up files regularly and upload them to the backup server by FTP

The code is as follows:

Rem backs up files regularly and uploads them to the backup server by FTP

Folder to be backed up by rem

Set bak_webFile=F:\ backup\

Rem temporary folder

Set bak_tmpFile=C:\ ~ UpTemp\

Rem Log folder

Set bak_logPath=C:\ ~ bak_log\

Rar file name generated by rem

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-start compressing [% bak_timeStart%] >% bak_logPath%log-%bak_date%.txt

"C:\ Program Files\ WinRAR\ Rar.exe" a-ag+%bak_bakFile%% bak_tmpFile%% bak_webFile%

Echo-Compression completed, start uploading [% time%/%bak_timeStart%] > >% bak_logPath%log-%bak_date%.txt

Rem generates ftp command file

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 completed [% time%/%bak_timeStart%] > >% bak_logPath%log-%bak_date%.txt

Thank you for reading this article carefully. I hope the article "how to back up files and upload them to the bat of FTP server" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Backup file server service folder article generation code information command date format value interest at the same time file name log more friends knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno macOS Shulou Technology Linux Shulou Information