澳洲大头 发表于 2011-6-10 10:53:07

MS SQL Server database backup solution

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 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
页: [1]
查看完整版本: MS SQL Server database backup solution