My previous project, use the Bat+windows scheduled task to automatically back up data to a backup server.
In the handover, write this thing out and hopefully inspire you to use the bat script more.
One. Prepare and write the bat file for ease of maintenance split 3 files are: Bakmain.bat bakdatalog.bat (compressed and write log) ftp.txt (FTP command file)
Bakmain.bat
@echo OffSET spath = REM log path defaults to the current path of echo ###################%date%#%time% execution: ######################### >>% spath%run.logdel/q D:\newbak\ backup file prefix *.rar >>%spath%run.log REM first delete old data backup file echo ######### #打包: ########## >> %spath%run.logcall bakdatalog.bat >>%spath%run.log REM call the command line within the packaged file and package the work echo ######### #上传: ########## >>%spath%run.logftp-s:ftp.txt >>%spath%run.log REM call FTP command line for FTP transfer file echo ######### #完成时间:%time% >>%spath%run.log
Bakdatalog.bat
RAR program path a-m5-r-hp password-p password
The code uses the command line of the RAR program to compress the specified directory and set the password and other information specific data can view WinRAR's help or other compression tool notes to modify parameters
Ftp.txt
Open 192.168.0.226 rem opens an FTP link account password cd file upload target path REM with directory not write promptput D:\newbak\ backup file prefix *.rarbye
To this preparation work with the bat code is basically done. Of course it's just an application, and we can use bat for a lot of other ways.
Two. Set up automatic scheduled Task 1. Open Scheduled Task management tool start, Administrative tools, Task Scheduler
2. Select the Task Scheduler library from the left
3. Right-click on the right and select Create Basic task
4. Follow the wizard to create 4.1 to fill in the scheduled task: name, description. Next
4.2 Select the task start time, here according to the backup cycle needs to choose; next
4.3 Set start time and execution interval; next step
4.4 Select the startup program; next
4.5 Program or script: Browse and select the Bakmain.bat we just created; parameters and start with flow empty; next
4.6 Complete
Here we set up the automatic backup using Bat+winrar and send to the specified FTP server.
Of course this is just an example of what we can do with Bat more.
Automatically packaged with bat and sent to the backup server via FTP