PVI_COPY

История резервных копий БД_Database backup history.sql

Mar 1st, 2021 (edited)
212
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --  
  2. -- История резервных копий БД_Database backup history.sql
  3. USE am___ -- DatabaseName
  4. GO
  5.  
  6. SELECT
  7. s.database_name,
  8. m.physical_device_name,
  9. CAST(CAST(s.backup_size / 1000000 AS INT) AS VARCHAR(14)) + ' ' + 'MB' AS bkSize,
  10. CAST(DATEDIFF(second, s.backup_start_date,
  11. s.backup_finish_date) AS VARCHAR(4)) + ' ' + 'Seconds' TimeTaken,
  12. s.backup_start_date,
  13. CAST(s.first_lsn AS VARCHAR(50)) AS first_lsn,
  14. CAST(s.last_lsn AS VARCHAR(50)) AS last_lsn,
  15. CASE s.[type]
  16. WHEN 'D' THEN 'Full'
  17. WHEN 'I' THEN 'Differential'
  18. WHEN 'L' THEN 'Transaction Log'
  19. END AS BackupType,
  20. s.server_name,
  21. s.recovery_model
  22. FROM msdb.dbo.backupset s
  23. INNER JOIN msdb.dbo.backupmediafamily m ON s.media_set_id = m.media_set_id
  24. WHERE s.database_name = DB_NAME() -- Remove this line for all the database
  25. ORDER BY backup_start_date DESC, backup_finish_date
  26. GO
  27.  
  28. --
  29.  
  30. /*
  31. USE msdb
  32. Go
  33. SELECT *
  34. FROM backupfile
  35. */
RAW Paste Data