|
The following has been tried and work well
In task scheduler:
- sqlcmd -i "E:\db_backup\ADbk.sql"
复制代码
where E:\db_backup\ADbk.sql is the backup script to run, which contains the codes:
- DECLARE @MyFileName varchar(50)
- SELECT @MyFileName = (SELECT 'E:\db_backup\ADbk_' + datename(dw,GetDate()) + '.bak')
- BACKUP DATABASE [AD] TO DISK = @MyFileName WITH NOFORMAT, INIT, NAME = N'AD-Full Database Backup'
- GO
复制代码
This will include day of the week in the backup file name. Thus 7 copies of backup files always kept.
Note
INIT = overwire existing file
NOINIT = append to existing file |
|