SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Differential backup question


Differential backup question

Author
Message
Abu Dina
Abu Dina
Hall of Fame
Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)

Group: General Forum Members
Points: 3015 Visits: 3325
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
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24650 Visits: 6519
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
Hall of Fame
Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)

Group: General Forum Members
Points: 3015 Visits: 3325
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
Mr or Mrs. 500
Mr or Mrs. 500 (563 reputation)Mr or Mrs. 500 (563 reputation)Mr or Mrs. 500 (563 reputation)Mr or Mrs. 500 (563 reputation)Mr or Mrs. 500 (563 reputation)Mr or Mrs. 500 (563 reputation)Mr or Mrs. 500 (563 reputation)Mr or Mrs. 500 (563 reputation)

Group: General Forum Members
Points: 563 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
Mr or Mrs. 500
Mr or Mrs. 500 (563 reputation)Mr or Mrs. 500 (563 reputation)Mr or Mrs. 500 (563 reputation)Mr or Mrs. 500 (563 reputation)Mr or Mrs. 500 (563 reputation)Mr or Mrs. 500 (563 reputation)Mr or Mrs. 500 (563 reputation)Mr or Mrs. 500 (563 reputation)

Group: General Forum Members
Points: 563 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
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1523 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 Guru
SSC Guru (226K reputation)SSC Guru (226K reputation)SSC Guru (226K reputation)SSC Guru (226K reputation)SSC Guru (226K reputation)SSC Guru (226K reputation)SSC Guru (226K reputation)SSC Guru (226K reputation)

Group: General Forum Members
Points: 226415 Visits: 46325
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