The housekeeper software comes with a backup function, either manually or only when the first exit is backed up, and is the specified directory, always less convenient and reliable. If you use a script plus Windows Task Scheduler, you can perform backup operations reliably and conveniently.
Environment Description:
Backup destination: Network shared directory-\\network_computer\backup
MSDE database name (housekeeper the accounting database):TEST
Tools or software to use: Osql,7zip,forfiles
Automatically delete backup files before a specified number of days
The batch script code is as follows:
REM BACKUP DATABASE to the TEMP directory d:\temp
"C:\Program Files\Microsoft SQL Server\80\tools\binn\osql.exe"-e-q "BACKUP DATABASE
T E ST TO DISK = ' d:\temp\test ' "
REM compressed file, stored in temp directory d:\temp, file name test+ Day date, formatted as YYYYMMDD
"C:\Program files\7-zip\7z.exe" a-t7z d:\temp\test%date:~0,4%%date:~5,2%%date:~8,2%. 7z d:\temp\test-mx9
REM Copy file to network share disk, Map network disk
net use W: \\network_computer\backup
Copy d:\temp\test%date:~0,4%%date:~5,2%%date:~8,2%. 7zW:/y
REM Specifies how many days before a file needs to be deleted
Set daysago=31
forfiles/p W:/s/m */d-%daysago%/C "cmd/c del/q @path"
REM Delete Network map disk
NET use W:/delete
REM Delete Net temp directory file
Del d:\temp\test*. */Q
This article is from the "hobby It Cattle" blog, please be sure to keep this source http://raydeng.blog.51cto.com/3499777/1410087