Αγαπητέ φίλε,
Σε ευχαριστώ για το γεγονός ότι επικροτείς την προσπάθεια μου και για το ότι είχες την διάθεση να παρακολουθήσεις τα πρώτα 25 λεπτά αυτής της τρίωρης (για την ακρίβεια 3 ώρες και 16 λεπτά) παρουσίασης μου.
Πραγματικά λυπάμαι που θεωρείς αυτή κόλαφο μου.
Ας έρθουμε όμως στις τραγικότητες της παρουσίασης μου και στις δικές μου
Αναφέρεις
«Στο simple recovery model μπορεις να γυρισεις στην στιγμη δημιουργιας ενος backup (δεν ειναι απαραιτητο να ειναι full backup μπορει να ειναι κ differential)»
Απαντώ
Αυτό που λες είναι απολύτως σωστό. Στο 14:48 τις παρουσίασης μου το αναφέρω, και όντως δεν ανέφερα ότι κάνεις restore και differential εφόσον φυσικά το έχεις πάρει πριν. Αυτό οφείλετε στο γεγονός ότι ακόμα δεν είχα μιλήσει για τους τύπους του backup και από την εμπειρία μου γνωρίζω ότι όσοι είναι σε simple recovery model σπάνια για να μην πω καθόλου δεν παίρνουν differential backup. Ας θεωρήσουμε λοιπόν ότι είναι παράληψη μου. Αναρωτιέμαι όμως έτσι που το αναφέρεις, μιας και εγώ δεν ξέρω, Πως μπορείς να κάνεις απευθείας restore to differential backup αν πρώτα δεν έχεις κάνεις restore to full?. Γιατί εγώ ξέρω ότι αν πας να κάνεις κάτι τέτοιο θα πάρεις το παρακάτω error
Msg 3118, Level 16, State 1 : The database "xxxx" does not exist. RESTORE can only create a database when restoring either a full backup or a file backup of the primary file.
Αυτό σημαίνει ότι πρέπει να γίνει πρώτα restore το full backup. Άρα γυρνάς στο τελευταίο full και εφόσον έχεις πάρει και differential τότε μπορείς να κάνεις και αυτό restore αρκεί να έχεις κάνει restore το full με norecovery.
Αναφέρεις
«Το bulk-logged λειτουργει οπως το Full με την εξαιρεση οτι καποιες ενεργειες στο bulk-logged μπορουν να καταγραφονται/logged minimally (εφοσον τηρουνται καποιες προυποθεσεις απαραιτητες για minimally logged operations):
Compared to the full recovery model, which fully logs all transactions, the bulk-logged recovery model minimally logs bulk operations, although fully logging other transactions.»
Απαντώ
Στο slide το οποίο είναι ορατό κατά την στιγμή που μιλάω για τα θέμα αυτό στο 3ο sub-bullet του Bulk Logged γράφω «Reduces log space usage by using minimal logging for most bulk operations». Επίσης στο 15:00 μιλάω για την διαφορά του full με το bulk-logged και εξηγώ πως αυτό γίνεται ( σε επίπεδο page για το full και extend για το bulk) και μάλιστα αναφέρω και παράδειγμα με την δημιουργία του index που είναι μια bulk διαδικασία έτσι δεν είναι ή κάνω λάθος;
Αναφέρεις
«Στα partial backups το παιχνιδι εχει χαθει ΕΝΤΕΛΩΣ:
Συμφωνα με τον ομιλητη στον SQL Server 2005 τα partial backups ειναι μονο για read-only files (sic!!!)
BOL 2005:
A partial backup resembles a full database backup, but a partial backup does not contain all the filegroups.
Instead, a partial backup contains all the data in the primary filegroup, every read/write filegroup, and any optionally-specified read-only files.
Partial backups are useful whenever you want to exclude read-only filegroups.
A partial backup of a read-only database contains only the primary filegroup.»
Απαντώ
Αντιγράφω από το επίσημο εκπαιδευτικό υλικό της Microsoft για το σεμινάριο 6231A με τίτλο Maintaining a Microsoft SQL Server 2008 Database και συγκεκριμένα από υλικό το οποίο υπάρχει στο CD που ο εκπαιδευόμενος παίρνει σαν εκπαιδευτικό υλικό.
«Partial and differential partial backups were introduced in SQL Server 2005. These backups are designed to provide more flexibility for backing up databases that contain some read-only filegroups under the simple recovery model. However, these backups are supported by all recovery models.»
Αναφέρεις
«Στα transaction log backups πλεον η παρουσιαση γινεται ΑΝΥΠΟΦΟΡΗ :
To transaction log backup παιρνει ΠΑΝΤΑ τις αλλαγες/την διαφορα/το delta απο το ΤΕΛΕΥΤΑΙΟ transaction log backup και ΜΟΝΟ (δεν εχει καμια σχεση με τα αλλα backups).
eg.
10:00 Full Backup
11:00 Transaction log backup
12:00 Differential Backup
13:00 Full Backup
14:00 Transaction log backup
To transaction log backup στις 14:00 περιεχει ολες τις αλλαγες στην βαση που πραγματοποιηθηκαν απο τις 11:00 κ μετα.»
Απαντώ
Αντιγράφω πάλι από το επίσημο εκπαιδευτικό υλικό της Microsoft για το σεμινάριο 6231A.
«Under the full recovery model or bulk-logged recovery model, regular transaction log backups (or log backups) are required. Each log backup covers the part of the transaction log that was active when the backup was created, and it includes all log records that were not backed up in a previous log backup. An uninterrupted sequence of log backups contains the complete log chain of the database, which is said to be unbroken. Under the full recovery model, and sometimes under the bulk-logged recovery model, an unbroken log chain lets you to restore the database to any point in time.»
Πέρα από αυτό και θεωρώντας δεδομένο ότι εγώ δεν γνωρίζω θα σε παραπέμψω σε ένα άρθρο του Paul Randal ο οποίος δεν νομίζω ότι χρειάζεται συστάσεις και στο post με τίτλο
A SQL Server DBA myth a day: (20/30) restarting a log backup chain requires a full database backup
Αναφέρει τα παρακάτω
This myth is one of the most common and I've come across very few people who know the truth.
Myth #20: after breaking the log backup chain, a full database backup is required to restart it.
FALSE
A normal transaction log backup contains all the transaction log generated since the previous log backup (or since the first ever full backup if it's the first ever log backup for the database). There are various operations that will break the log backup chain - i.e. prevent SQL Server from being able to take another log backup until the chain is restarted. The list of such operations includes:
• Switching from the FULL or BULK_LOGGED recovery models into the SIMPLE recovery model
• Reverting from a database snapshot
• Performing a BACKUP LOG using the WITH NO_LOG or WITH TRUNCATE_ONLY (which you can't do any more in SQL Server 2008 - yay!)
Here's an example script that shows you what I mean:
CREATE DATABASE LogChainTest;
GO
ALTER DATABASE LogChainTest SET RECOVERY FULL;
GO
BACKUP DATABASE LogChainTest TO DISK = 'C:\SQLskills\LogChainTest.bck' WITH INIT;
GO
BACKUP LOG LogChainTest TO DISK = 'C:\SQLskills\LogChainTest_log1.bck' WITH INIT;
GO
ALTER DATABASE LogChainTest SET RECOVERY SIMPLE;
GO
ALTER DATABASE LogChainTest SET RECOVERY FULL;
GO
Processed 152 pages for database 'LogChainTest', file 'LogChainTest' on file 1.
Processed 1 pages for database 'LogChainTest', file 'LogChainTest_log' on file 1.
BACKUP DATABASE successfully processed 153 pages in 0.088 seconds (14.242 MB/sec).
Processed 2 pages for database 'LogChainTest', file 'LogChainTest_log' on file 1.
BACKUP LOG successfully processed 2 pages in 0.033 seconds (0.341 MB/sec).
I created a database, put it into the FULL recovery model, started the log backup chain, and then momentarily bounced it into the SIMPLE recovery model and back to FULL.
Now if I try to take a log backup:
BACKUP LOG LogChainTest TO DISK = 'C:\SQLskills\LogChainTest_log2.bck' WITH INIT;
GO
Msg 4214, Level 16, State 1, Line 1
BACKUP LOG cannot be performed because there is no current database backup.
Msg 3013, Level 16, State 1, Line 1
BACKUP LOG is terminating abnormally.
SQL Server knows that I performed an operation which means the next log backup will NOT contain all the log generated since the previous log backup, so it doesn't let me do it.
The myth says that a full database backup is required to restart the log backup chain. In reality, all I need is a data backup that bridges the LSN gap. A differential backup will do:
BACKUP DATABASE LogChainTest TO DISK = 'C:\SQLskills\LogChainTest_Diff1.bck' WITH INIT, DIFFERENTIAL;
GO
BACKUP LOG LogChainTest TO DISK = 'C:\SQLskills\LogChainTest_log2.bck' WITH INIT;
GO
Processed 40 pages for database 'LogChainTest', file 'LogChainTest' on file 1.
Processed 1 pages for database 'LogChainTest', file 'LogChainTest_log' on file 1.
BACKUP DATABASE WITH DIFFERENTIAL successfully processed 41 pages in 0.083 seconds (4.040 MB/sec).
Processed 1 pages for database 'LogChainTest', file 'LogChainTest_log' on file 1.
BACKUP LOG successfully processed 1 pages in 0.010 seconds (0.768 MB/sec).
This is really cool because you don't need to take a (potentially very large) full database backup to be able to continue with regular log backups.
If you have a backup strategy that involves file or filegroup backups as well as database backups, you can even restart the log backup chain after a single file differential backup! Take note, however, that to be able to restore that database, you'd need to have a data backup of each portion of it that bridges the LSN gap (i.e. a file or filegroup full or differential backup) but that's more complicated than I want to go into in this post.
Another myth bites the dust!
Πέρα όμως από αυτό σου έχω και εγώ ένα δικό μου παράδειγμα
create database demo
go
create table demo.dbo.t1 ( id int identity(1,1) primary key, data nvarchar(100))
go
insert into demo.dbo.t1 values ('record-1')
go
exec sp_addumpdevice 'disk','dev1','c:\temp\dev1.bak'
go
backup database demo to dev1 with description='full', init
go
insert into demo.dbo.t1 values ('record-2')
go
backup log demo to dev1 with description = 'tlog1'
go
insert into demo.dbo.t1 values ('record-3')
go
backup database demo to dev1 with differential, description = 'differential'
go
insert into demo.dbo.t1 values ('record-4')
go
backup log demo to dev1 with description = 'tlog2'
go
select * from demo.dbo.t1
go
Το οποίο βλέπεις έχει ένα full μετά ένα log κατόπιν ένα diff και τέλος πάλι ένα log backup.
Αν έρθουμε να εκτελέσουμε την
restore headeronly from dev1
go
Θα πάρουμε ένα μεγάλο σε μήκος αποτέλεσμα που θα μας πει πολλά πράγματα αλλά το κόβω για να εστιάσω σε αυτά που μας αφορούν έχουμε τα εξής
BackupDescription Position DatabaseName FirstLSN LastLSN CheckpointLSN DatabaseBackupLSN
---------------------- --------- ------------------ ------------------------- ------------------------- ------------------------- -----------------
full 1 demo 23000000007700196 23000000015900001 23000000007700196 0
tlog1 2 demo 23000000007700196 23000000016800001 23000000007700196 23000000007700196
differential 3 demo 23000000016900039 23000000018600001 23000000016900039 23000000007700196
tlog2 4 demo 23000000016800001 23000000018700001 23000000016900039 23000000007700196
Εφόσον είμαστε στην θέση να ερμηνεύσουμε το παραπάνω αποτέλεσμα θα καταλάβουμε ότι ισχύει αυτό που είπα, αν και δεν νομίζω ότι χρειάζεται γιατί εύκολα βγαίνει σαν συμπέρασμα από τα λεγόμενα του Randal παραπάνω. Επίτηδες αναφέρω το filed DatabaseBackupLSN για να εξηγήσω ότι αυτό είναι πάντα το ίδιο καθώς η βάση μου είναι το full backup.
Τέλος αν ίσχυε ο ισχυρισμός σου θα μπορούσα να κάνω restore χωρίς να εμπλέξω το differential backup.
Φιλικά
Υ.Γ. Εγώ έχω μάθει όταν κάνω σχόλια να τα κάνω με το όνομα μου από κάτω.
Antonios Chatzipavlis