Jump to content
  • entries
    292
  • comments
    368
  • views
    59872

Μήπως έχετε ξεχάσει κάποια database να την πάρετε backup;


antonch

709 views

 Share

Είστε σίγουροι ότι έχετε πάρει έστω και μια φορά όλες τις databases σας backup;

Ειδικά εσείς αγαπητοί συνάδελφοι που έχετε πολλές databases είστε σίγουροι;

Η απάντηση στο ερώτημα αυτό είναι η παρακάτω stored procedure η οποία θα σας επιστρέψει αμέσως όλες τις database που έχετε ξεχάσει να πάρετε backup.

 

create proc dbo.spUnbackupedDbs 
@backup_type char(1)='D',
@time_span_days int=5
as
-- Created by Antonios Chatzipavlis
--
-- This stored procedure returns all databases in a server
-- ( except model and tempdb ) at which I have not take any backup
-- for a specific days from the current day
--
-- Parameters
--
-- @backup_type : defines the backup type
-- VALID VALUES
-- 'D' : Full Backup (DEFAULT VALUE)
-- 'I' : Diffential
-- 'L' : Transaction Log
-- 'F' : File or Filegroup
-- 'G' : File Diffential
-- 'P' : Partial
-- 'Q' : Partial Differential
--
-- @time_span_days : defines the amount of days ( DEFAULT VALUE is 5 DAYS )

select
a.[name] as database_name
from master.dbo.sysdatabases a
left join msdb.dbo.backupset b on a.[name] = b.database_name
and
datediff(day,b.backup_finish_date,getdate()) and
b.type=@backup_type
where a.[name] not in ('model','tempdb')
and b.database_name is null
go


Δημιουργήστε πρώτα την stored procedure τρέχοντας το παραπάνω script και εφόσον όλα πάνε καλά εκτελέστε την όπως παρακάτω



 



exec spUnbackupedDbs
 Share

3 Comments


Recommended Comments

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...