Under Windows data is automatically backed up to the server via FTP and the backup before the specified number of days is deleted

  • 2020-05-09 19:41:55
  • OfStack

Description:

1. The files to be backed up are in the D root directory, named after the time
D:\data_db_201112130001.BAK
D:\data_db_201112140002.BAK
D:\data_db_201112150003.BAK
A new file will be automatically generated every day. For example, on December 16, 2011, data_db_201112160004.BAK will be automatically generated


For example, today is December 16, 2011. The file data_db_201112160004.BAK should be uploaded to FTP server, and the data 7 days ago should be deleted (only the last 7 days of backup should be kept).
ftp server: 192.168.1.1
Port: 21
User name: admin
Password: 123456
Backup file directory databak


Save the following code to data.bat, add it to windows's scheduled tasks, and do it automatically every day.

 
@echo off 
echo. 
set data=%date:~0,4%%date:~5,2%%date:~8,2% 
set /a deldata=data-7 
echo open 192.168.1.1 21 >ftp.txt 
echo admin>>ftp.txt 
echo 123456>>ftp.txt 
echo binary>>ftp.txt 
echo cd databak>>ftp.txt 
echo lcd D:\>>ftp.txt 
echo prompt>>ftp.txt 
echo mput data_db_%data%*.BAK >>ftp.txt 
echo mdelete data_db_%deldata%*.BAK >>ftp.txt 
echo close>>ftp.txt 
echo bye>>ftp.txt 
ftp.exe -s:ftp.txt 
echo. 


For better stability, I will use rsync to implement backup, which is more convenient. Above software everyone to this site server common software column download.


Related articles: