sqlschool.gr logo

articles

Articles of SQLschool.gr Team

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

Antonios Chatzipavlis
Thursday 02 July 2009

Είστε σίγουροι ότι έχετε πάρει έστω και μια φορά όλες τις 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())<@time_span_days
and
b.type=@backup_type
where a.[name] not in ('model','tempdb')
and b.database_name is null
go

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

exec spUnbackupedDbs

Antonios Chatzipavlis

Antonios Chatzipavlis

Antonios Chatzipavlis is a highly experienced Data Solutions Consultant and Trainer. He has been working in the IT industry since 1988, holding various roles such as senior developer, IT Manager, Data & AI Solutions Architect and Consultant.

Since 1995, Antonios has focused on modern technologies and software development tools, primarily by Microsoft. He has specialized in Data & AI since 2000, with expertise in Microsoft Data Platform (SQL Server, Azure SQL Databases, Azure Synapse Analytics, Microsoft Fabric, Power BI, AI) and Databricks.

Antonios is also a Microsoft Certified Trainer (MCT) for over 25 years, has been recognized as a Microsoft Most Valuable Professional (MVP) in Data Platform since 2010 and he is in the Data Expert 40 Powerlist 2024 by Boussias. He is the co-founder and visionary behind XLYTiCA, a company dedicated to Data & AI solutions.

Episode

Task Flows in Microsoft Fabric

image

More Episodes...

Tip

Get Certified: Become a Fabric Data Engineer

More Tips...

Become a member

If you want to receive updates from us become a member to our community.

Connect

Explore

Learn

sqlschool.gr © 2010-2025 All rights reserved

This site uses cookies for operational and analytics purposes only. By continuing to browse this site, you agree to their use.