|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Today @ 10:34 AM
Points: 494,
Visits: 2,158
|
|
I would really appreciate it if someone could help understand the following.
I have a stored procedure to backup all user databases on an instance.
Example (D for Differential, F for FULL and L for Log
exec [sp_QB_Backup] @BackupType = 'D', @BackupFolderPath = '\\FileStoreBackup\' I did the following the test:
1) Created a blank database called Test 2) Ran the above (failed on backing up Test database - fair enough as there isn't a full backup 3) Queried backupset table, no entries for Test DB yet. 4) Restored another database backup on top of the Test DB, rechecked backupset table, still no entry for Test DB. 5) Ran the differential backups again and it worked creating one.
But I never did a full backup of the Test DB so how can it do a differential? Is it because I restored from a FULL backup that SQL is using to work out the differential for the Test DB?
----------------------------------- http://www.SQL4n00bs.com
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Tuesday, May 21, 2013 1:55 PM
Points: 15,442,
Visits: 9,571
|
|
It's doing a Diff on the one you restored. Obviously, that database has a restorable Full backup, since you just used it to restore the database, so it can do a Diff on it.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Today @ 10:34 AM
Points: 494,
Visits: 2,158
|
|
Hmmmm.... that's what I thought so thanks for confirming.
The reason I'm asking is because I have a job which performs daily differential backups and another which does fortnightly full backups.
So consider the following scenario:
DAY 1 - FULL Backups Day 2 - Differential Backups DAY 3 - NEW DATABASE added DAY 3 - Differential Backups (will fail the job because there isn't a full backup for the new database).
So I thought I could add a check in my sproc to look for entries in the backupset table where the type is D but this won't work where a database is created then restored using a full backup from another database. I know the differential won't fail but it would be confusing to find a differential backup in the backup folder but no full backup.
am I making sense?
----------------------------------- http://www.SQL4n00bs.com
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Tuesday, May 21, 2013 1:55 PM
Points: 15,442,
Visits: 9,571
|
|
I build separate logging into that kind of script. It checks its own log to see if a database has had a full backup in the expected timeframe. If not, it runs one, if so, it does a Diff.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Today @ 10:34 AM
Points: 494,
Visits: 2,158
|
|
Yup... I did entertain this idea of custom logging before but I thought I'd check with you guys in case I'm duplicating unnecessary metadata. But it does make sense and it will give me more control.
----------------------------------- http://www.SQL4n00bs.com
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Tuesday, May 21, 2013 1:55 PM
Points: 15,442,
Visits: 9,571
|
|
Because I use custom maintenance scripts, I maintain a log of "actions done per database". Rebuild some indexes? Log it. Run a backup? Log it. DBCC CHECKDB? Log it. And so on. Gives a one-stop table where all of a database's history is kept. Can get a full history for any database, or the whole server, without having to query dozens of system views.
Same database (DBA is the name of the database) has a DDL log in it for all object create/modify/drop commands. So it becomes easy to see things like, "What's the best backup to use if I want to restore to before that $%&*!@# moron dropped those tables?"
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
|
|
|
|