Preparation tools:
SqlServer2008
WinRar
1. Set up maintenance schedule scheduled backups for SQL Server
This is a simple operation, and you can follow the wizard to add a maintenance plan.
2. Automatic compression scripts
c:\progra~2\winrar\winrar.exe a D:\bak\database_buckup_%date:~0,4%_%date:~5,2%_%date:~8,2% D:\bak\database_*%Date:~0,4%_%date:~5,2%_%date:~8,2%_*.Bak
The format of the backup file is: Database_backup_2015_05_15_010001_5555338.bak,
The compressed file format is: Data_2015_06_15.rar this style.
3. Automatic deletion of old backups
Set up a scheduled task to remove the old backup before compressing it. The VBS script is invoked here through the bat script because the VBS script is relatively well-written.
Autodeleteold.bat
cscript d:/bak/autoDeleteOldBak.vbs
Autodeleteoldbak.vbs
ConstRemaincount =1 ' Keep a few dayDimFso,dc,file,files,folder,subfolders,subfolderSetfso=CreateObject("Scripting.FileSystemObject")SetFolder=fso.getfolder ("D:\bak")Dimtodaytoday= Now for eachTempfileinchFolder.filesDimArr arr=Split(Tempfile,"_backup_")if UBound(arr) >0 Then DimTempdate,diff tempdate=Cdate(Replace( Left(Arr (1),Ten),"_","-")) diff=DateDiff("D", Tempdate,today)if(Diff>remaincount) ThenFso.deletefile (Tempfile),true End if End ifNextSetfso= Nothing
If you have another FTP server, you can compress the files and synchronize them remotely to another server.
SQL Server automatic backup, automatic compression, automatic deletion of old backups