Description
Use task scheduling to execute batch files at specified times per day;
1. Implement automatic copy database backup file to a different host
2, automatically delete the specified number of days of backup files
1. Batch processing file code Copydb2lan (factory). bat
Code starts at *************************
@echo off
Color 0e
Cls
Title Copy DB to The Mirror host (by [email protected]) ...
Set Desthost=\\172.32.4.252\sfisbackup
Set Lc=y:
Set Work_path=d:\sfisbackup
Set Stg_name=d:\sfisbackup\stg_123456.txt
Set pskip=4
NET use%lc%%desthost% "[email protected]"/user:administrator
FOR/R%work_path%%%i in (Sfis*.bak) do echo%%i >>%stg_name%
for/f "skip=%pskip%"%%i in (%stg_name%) do set cpfilename=%%i
Copy%cpfilename%%lc%/y
If exist%stg_name% del/q%stg_name%
NET use%lc%/del
At the end of the code *************************
2. Batch processing file code Cleanolddb.bat
At the end of the code *************************
@echo off
Lolor @e
Cls
Title Delete files N days ago (by [email protected]) ...
Set Work_path=d:\sfisbackup
Set Stg_name=d:\sfisbackup\stg_123456.txt
Set dd=10
forfiles/p "%work_path%"/s/m */d-%dd%/C "cmd/c del/q @path"
Pause
At the end of the code *************************
This article is from the "Imagine the Sky" blog, please be sure to keep this source http://kinwar.blog.51cto.com/3723399/1421526