Full Backup with compression z oznaczeniem pliku .bak i zrzuceniem statystyk wykonania co 5%
--full backup with compression
declare @db varchar(100) = 'test1'
declare @path varchar(200) = 'Y:\Backup\'
declare @tmark varchar(20) = (select Format(GetDate(), N'_yyyyMMdd_HHmm'))
declare @sql varchar(max)
set @sql = 'backup database ' + @db + ' to disk = N''' + @path + @db + @tmark + '.bak'' with compression, stats = 5;'
print @sqlselect
[database_name],
[recovery_model],
backup_size,
compressed_backup_size,
cast((backup_size/compressed_backup_size)as numeric(3,2)) as compressionRatio,
backup_start_date,
backup_finish_date,
datediff(second,backup_start_date,backup_finish_date) as BackupCompleteTimeSec
from
msdb.dbo.backupset
order by 6 desc
exec(@sql)