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


Database backups best practice


Database backups best practice

Author
Message
Mike Hinds
Mike Hinds
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1391 Visits: 1134
sharon (4/30/2008)
mike please can you explain with examples to make it more clear


Sharon,

1) The Weekly Full Backup job, which runs Sundays at 7 pm, has the following steps:

backup database [MyDB] to [MyDB]
with init, name=N'MyDB', description=N'Weekly Full'

backup log [MyDB] to [MyDB_Log]
with init, name=N'MyDB', description=N'Init'


2) The Daily Differential Backup job, which runs Mon-Sat at 7 pm, has the following steps:

backup database [MyDB] to [MyDB]
with differential, name=N'MyDB', description=N'Diff'

backup log [MyDB] to [MyDB_Log]
with init, name=N'MyDB', description=N'Init'


3) The "hourly" log backup runs every 15 minutess from midnight to 6:45 pm, Sun - Sat, and includes the following step:

backup log [MyDB] to [MyDB_Log]
with name=N'MyDB_Log', description=N'Hourly'


The backup device can be created from the GUI, or with the following T-SQL:

declare @DB Nvarchar(50)
declare @device Nvarchar(50)
declare @BackupFolder nvarchar(255)
declare @DeviceFile nvarchar(255)

set @DB = N'DB_Name'
set @BackupFolder = N'S:\SqlBackups\'

set @device = @DB
set @deviceFile = @BackupFolder + @device + '.Bak'
exec sp_addumpdevice @devtype = 'disk', @logicalname = @device, @physicalname = @deviceFile

set @device = @DB + N'_Log'
set @deviceFile = @BackupFolder + @device + '.Bak'

exec sp_addumpdevice @devtype = 'disk', @logicalname = @device, @physicalname = @deviceFile


Change @DB and the path for @BackupFolder to whatever will work in your environment. Makes a device for both MyDB and MyDB_Log.

For performance reasons, the backup works best if the destination is on separate media from the database files and logfiles. This is also desirable if your backup is to be used in case of a local drive failure.

Mike Hinds
Senior Database Administrator
1st Source Bank
MCP, MCTS
Mike Hinds
Mike Hinds
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1391 Visits: 1134
nkm129 (4/30/2008)
This is showing error

Incorrect syntax near '+'.


You will need something like this:

declare @BakFile char(50)
set @BakFile = 'S:\SqlBackups\DbName '+convert(char(8),getdate(),112)+'.bak'
backup database DbName to disk = @BakFile


Again, this will append Year-Month-Day, but you will need to do additional work to clear out the colons if you are looking to add hours-minutes, as you would for a log backup that occurs more than once a day. Check out Books Online (BOL) for syntax of CONVERT for datetime types.

Mike Hinds
Senior Database Administrator
1st Source Bank
MCP, MCTS
amod.professional
amod.professional
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 70
hi,

I have data of 182 GB and ram 16gb with 8 logical cpus(2 quad core)

and [erfromance is very poort due to 13.45 GB of RAM is in used with sql server only and cache hit ratio is 90-85% every time.
ALZDBA
ALZDBA
SSC-Dedicated
SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)

Group: General Forum Members
Points: 30385 Visits: 8986
amod.professional (2/21/2012)
hi,

I have data of 182 GB and ram 16gb with 8 logical cpus(2 quad core)

and [erfromance is very poort due to 13.45 GB of RAM is in used with sql server only and cache hit ratio is 90-85% every time.

Please start a new thread providing the information as requested in my signature.

Johan


Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere w00t

- How to post Performance Problems
- How to post data/code to get the best help


- How to prevent a sore throat after hours of presenting ppt ?


press F1 for solution, press shift+F1 for urgent solution :-D


Need a bit of Powershell? How about this

Who am I ? Sometimes this is me Alien but most of the time this is me Hehe
john.campbell-1020429
john.campbell-1020429
SSC Veteran
SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)

Group: General Forum Members
Points: 272 Visits: 336
Here is how I parse the name of the backup file

Select @vDBName = DatabaseName From @vDBList Where DBID = @vCount
Set @vNewpath = @vBackupPath
Set @vFileName = @vDBName + '_Full_' + REPLACE(REPLACE(REPLACE(Convert(Varchar(16), GetDate(), 120),'-',''),' ',''),':','') + '.bak'
Set @vBackupString = 'BACKUP DATABASE [' + @vDBName + '] TO DISK = ''' + @vNewPath + @vFileName +''''
GilaMonster
GilaMonster
SSC Guru
SSC Guru (228K reputation)SSC Guru (228K reputation)SSC Guru (228K reputation)SSC Guru (228K reputation)SSC Guru (228K reputation)SSC Guru (228K reputation)SSC Guru (228K reputation)SSC Guru (228K reputation)

Group: General Forum Members
Points: 228864 Visits: 46344
Please note: 4 year old thread.

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


prashanthreddygdwh
prashanthreddygdwh
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 48
Could you please send the scripts to prashanthreddygdwh@gmail.com as mentioned in your earlier post? Thanks...
radu.gheorghiu
radu.gheorghiu
SSC-Enthusiastic
SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)

Group: General Forum Members
Points: 103 Visits: 271
This is such a valuable thread! I have read all of your questions/answers and also searched on the internet for more possible best practices and I have wrote an article which tries to summarise all of these ideas and suggestions.

Please find my article here: http://sqlbak.com/blog/backup-best-practices/ and leave a comment if you consider that there is something else I might have missed. I hope this will help others and be a little time-saver.

Otherwise, this is a fantastic forum!

~ Just some guy trying to tune queries ~
maximo121
maximo121
SSC Rookie
SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)

Group: General Forum Members
Points: 39 Visits: 10
great! I needed this.

Max
itmanagers
itmanagers
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 3
Hi,

Hope you are doing fine.

I'm new using SQL backup jobs with multiple full, diff and log backups.

I have the following scenario

full- every day at 8:00pm
diff- every 4 hours
log- every 30 minutes

with full and diff I think there's no issues, however, I have the following issue with log backups,

every time a new log backup is executed, a new file of 6GB is created, for example if a log backup of 6,163,694 KB is created, the next log backup size is 6,165,294 kb is created

as far as I know there's an option to create log backups with only the size difference between them.

Could you please give a hand with this?

thanks in advance
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