Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««1234

Database backups best practice Expand / Collapse
Author
Message
Posted Thursday, May 01, 2008 5:44 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Yesterday @ 5:36 AM
Points: 590, Visits: 839
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.




Regards, Mike
Post #493498
Posted Thursday, May 01, 2008 5:59 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Yesterday @ 5:36 AM
Points: 590, Visits: 839
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.


Regards, Mike
Post #493501
Posted Tuesday, February 21, 2012 12:30 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, September 26, 2013 2:43 AM
Points: 1, Visits: 66
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.
Post #1255032
Posted Tuesday, February 21, 2012 12:41 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Wednesday, April 09, 2014 11:34 PM
Points: 6,997, Visits: 8,409
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


Don't drive faster than your guardian angel can fly ...
but keeping both feet on the ground won't get you anywhere

- 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"


Need a bit of Powershell? How about this

Who am I ? Sometimes this is me but most of the time this is me
Post #1255036
Posted Wednesday, February 22, 2012 1:43 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, March 24, 2014 6:35 AM
Points: 56, Visits: 328

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 +''''
Post #1256269
Posted Wednesday, February 22, 2012 2:03 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 3:54 PM
Points: 41,515, Visits: 34,430
Please note: 4 year old thread.


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
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

Post #1256280
Posted Friday, May 31, 2013 8:19 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, June 02, 2013 6:48 AM
Points: 1, Visits: 46
Could you please send the scripts to prashanthreddygdwh@gmail.com as mentioned in your earlier post? Thanks...
Post #1458911
« Prev Topic | Next Topic »

Add to briefcase «««1234

Permissions Expand / Collapse