Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Differential backup question


Differential backup question

Author
Message
Abu Dina
Abu Dina
Right there with Babe
Right there with Babe (723 reputation)Right there with Babe (723 reputation)Right there with Babe (723 reputation)Right there with Babe (723 reputation)Right there with Babe (723 reputation)Right there with Babe (723 reputation)Right there with Babe (723 reputation)Right there with Babe (723 reputation)

Group: General Forum Members
Points: 723 Visits: 3323
I do FULL backups every two weeks and daily differentials on a number of SQL instances.

The backup command I use for the differential backups in my sproc is like the below:

BACKUP DATABASE MyDatabase TO DISK = 'MyDatabase.Differential' WITH DIFFERENTIAL,  NAME = 'MyDatabase Differential Backup' , BUFFERCOUNT = 1024, CHECKSUM



At the end of a two week cycle I end up with two files

MyDatabase.FULL - Day 1
MyDatabase.Differential - DAY13

When I do my restores I start with the FULL obviously and then my latest differential. at this stage I am given the option to choose from 13 files, 1 for each day of the differential backup. This is great because it means I can restore to any day I want but what I don't get is, I am not creating a new differential backup file. I am overwriting the backup file using the same name. How does SQL Server work this out?

Hope I make sense!

---------------------------------------------------------


It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
David Edwards - Media lens

Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
Howard Zinn
anthony.green
anthony.green
SSCertifiable
SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)

Group: General Forum Members
Points: 6091 Visits: 6069
You dont have an INIT and FORMAT so it is appending the diff backup to the media set not overwriting it, so it contains all 13 days diff backups.

Highly risky move, should be backing up to individual files not one big file, as should anything happen to that 1 file you cannot restore to any of the subfiles contained within.



Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
When a question, really isn't a question - Jeff Smith
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger


Abu Dina
Abu Dina
Right there with Babe
Right there with Babe (723 reputation)Right there with Babe (723 reputation)Right there with Babe (723 reputation)Right there with Babe (723 reputation)Right there with Babe (723 reputation)Right there with Babe (723 reputation)Right there with Babe (723 reputation)Right there with Babe (723 reputation)

Group: General Forum Members
Points: 723 Visits: 3323
Thank Tony. I've re-read the info on the BACKUP DATABASE command and I see what you mean.

Lucky I've not had any files get corrupted YET!

---------------------------------------------------------


It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
David Edwards - Media lens

Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
Howard Zinn
db4breakfast
db4breakfast
SSC-Addicted
SSC-Addicted (441 reputation)SSC-Addicted (441 reputation)SSC-Addicted (441 reputation)SSC-Addicted (441 reputation)SSC-Addicted (441 reputation)SSC-Addicted (441 reputation)SSC-Addicted (441 reputation)SSC-Addicted (441 reputation)

Group: General Forum Members
Points: 441 Visits: 389
anthony.green (2/14/2013)
You dont have an INIT and FORMAT so it is appending the diff backup to the media set not overwriting it, so it contains all 13 days diff backups.

Highly risky move, should be backing up to individual files not one big file, as should anything happen to that 1 file you cannot restore to any of the subfiles contained within.


Agree. I put each backup to a separate file with name of the database, type of backup, and time stamp. example: TestDB_Full_20130305_235548.BAK

--------------------------------------------------------------------------------------
Hai Ton
My Db4Breakfast blog.
db4breakfast
db4breakfast
SSC-Addicted
SSC-Addicted (441 reputation)SSC-Addicted (441 reputation)SSC-Addicted (441 reputation)SSC-Addicted (441 reputation)SSC-Addicted (441 reputation)SSC-Addicted (441 reputation)SSC-Addicted (441 reputation)SSC-Addicted (441 reputation)

Group: General Forum Members
Points: 441 Visits: 389
Abu Dina (2/14/2013)
I do FULL backups every two weeks and daily differentials on a number of SQL instances.

The backup command I use for the differential backups in my sproc is like the below:

BACKUP DATABASE MyDatabase TO DISK = 'MyDatabase.Differential' WITH DIFFERENTIAL,  NAME = 'MyDatabase Differential Backup' , BUFFERCOUNT = 1024, CHECKSUM



At the end of a two week cycle I end up with two files

MyDatabase.FULL - Day 1
MyDatabase.Differential - DAY13

When I do my restores I start with the FULL obviously and then my latest differential. at this stage I am given the option to choose from 13 files, 1 for each day of the differential backup. This is great because it means I can restore to any day I want but what I don't get is, I am not creating a new differential backup file. I am overwriting the backup file using the same name. How does SQL Server work this out?

Hope I make sense!


You can use a dynamic tsql string and build the file_name in this format:

fileName = databaseName + '_' + backupType + '_' + dateTime + fileExtension

just declare these variables with varchar data type. For the dateTime, use the convert or cast function to convert to varchar.

Hope this helps.

--------------------------------------------------------------------------------------
Hai Ton
My Db4Breakfast blog.
SQL Show
SQL Show
Old Hand
Old Hand (393 reputation)Old Hand (393 reputation)Old Hand (393 reputation)Old Hand (393 reputation)Old Hand (393 reputation)Old Hand (393 reputation)Old Hand (393 reputation)Old Hand (393 reputation)

Group: General Forum Members
Points: 393 Visits: 1078
anthony.green (2/14/2013)
Highly risky move, should be backing up to individual files not one big file, as should anything happen to that 1 file you cannot restore to any of the subfiles contained within.


Anthony Green, Could you please explain me? If 1 file corrupted, can not I restore 5th differential file?
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47165 Visits: 44346
SQL Show (3/7/2013)
anthony.green (2/14/2013)
Highly risky move, should be backing up to individual files not one big file, as should anything happen to that 1 file you cannot restore to any of the subfiles contained within.


Anthony Green, Could you please explain me? If 1 file corrupted, can not I restore 5th differential file?


No, because the scenario described there are multiple backups in a single file, corrupt the file and all backups are gone, not just one.


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search