1. 程式人生 > >查看備份記錄

查看備份記錄

rop add type exe char 數據庫 art where ase

--回檔策略
--一、源數據庫改名
use master
go
EXEC sp_renamedb ‘db_tank‘, ‘db_tank_backup‘

--二、查看數據備份記錄,並備份

SELECT
CONVERT(CHAR(100),SERVERPROPERTY(‘Servername‘))AS Server,
bs.database_name,
bs.backup_start_date,
bs.backup_finish_date,
bs.expiration_date,
CASE bs.type
WHEN ‘D‘ THEN ‘Database‘
WHEN ‘L‘ THEN ‘Log‘
END AS backup_type,
bs.backup_size,
bmf.logical_device_name,
bmf.physical_device_name,
bs.name AS backupset_name,
bs.description,
‘RESTORE DATABASE [‘+bs.database_name+‘] FROM DISK=N‘‘‘
+bmf.physical_device_name+ ‘‘‘WITH NORECOVERY;‘ as ‘restore_sql‘,
row_number() over()

FROM msdb.dbo.backupmediafamily bmf
INNER JOIN msdb.dbo.backupset bs
ON bmf.media_set_id=bs.media_set_id

WHERE bs.backup_start_date>DATEADD(DAY,-3,GETDATE())
AND bs.backup_start_date >=‘20181106 2:05:00‘
AND bs.backup_start_date <= ‘20181106 10:05:00‘
order by bs.backup_start_date

查看備份記錄