Showing posts with label searches. Show all posts
Showing posts with label searches. Show all posts

Sunday, March 11, 2012

Differential Backups

Hi Folks!

I did a few searches and found some interesting threads but was not able to understand much. :)

I recently jumped from support to a DBA position and am learning about SQL Server 2000.

My dilemma: We have a SQL 2000 server with about 500GB's worth of databases that has some jobs from the app locking up due to tape backups. I am performing Full nightly and 1/2hour transaction SQL backups. We run daily differential and weekly full tape backups. It is taking 14 hours to run tape backups daily, causing some of the application jobs to fail. So to test it, I stopped the tape job to run one night and none of the App jobs failed.

So, I am hoping that if I start running nightly differentials, weekly fulls, and 1/2 hour trans, it should work. However, I am not very familiar with Differential jobs as till today i have been using maintenance plans. :confused:

My ideal scenario is this: Differentials start on Sat morning and stop before the weekly backup runs on Friday and then delete the older file when starting a new one. Is this possible? how?

C= OS, D=Backup (Raid 0), G=Data (Raid 5), E=Logs(Raid5).

Any help would be appreciated, and obviously if I have missed some piece of information, please feel free to ask.You're plan seems reasonable. So what's the problem, can't you choose differential backups in your maintplan?

To give you an alternative...
We had similar problems as we're backing up several TB of databases each day. We eventually solved this by using multiple tape units and decreased the size of the backups by using a compression backup tool.|||Haha.. the problem is this:

I can setup a differential job to create a diff file and then append to it till Friday evening. But Sunday I would want a new one to start OR 'clean' the old one and recreate it OR delete the old one and start a new one. You know what i mean? like the maintenance plan does for tlogs/full backups..

Does that make sense? We do not have a third party compression tool and we're cheap .. heh.

oh btw, can't create a maintenance plan for differentials in SQL 2000. :)|||Do the backups need to be appended to an existing one? You can create seperate files for each full, diff and tx backup.

This also has the advantage that you can restore a smaller volume from tape when, say, you wanted to restore until a certain monday.|||Hi Lexiflex,

Please help my dumb ass understand this right.. Heh..

So, i will have 3 jobs right?
1. A weekly full backup that runs on sat and after done deletes the older file
2. Transaction logs that run every 1/2 hour and delete files from 24 before after done.
3. This is where the confusion is..

A differential job that creates a nightly file or appends to it and then when the new week starts, it starts from scratch...

So when it is time to restore, I restore the weekly full then the appended diff file or the diff files from each night after the weekly and then transaction logs upto the time of failure.. right?

I am short on space on the server so that's why i need to delete the older files..

Makes sense?|||Step 3 should be:
3. A differential job that runs nightly from sun - fri and deletes the previous diff backup

I get the feeling your confusion is how to tell the differential backup when to start anew. Don't worry about this because SQL remembers when the last full backup was made and starts from there.

As for the other question:
So when it is time to restore, I restore the weekly full then the appended diff file or the diff files from each night after the weekly and then transaction logs upto the time of failure.. right?
Not quite, a differential backup in SQL 2000 consists of the data that has changed since the last FULL database backup. So when restoring:
1. Restore the weekly full
2. Restore the diff closest to but before the failure
3. Resore the tx backups until just before the failure

But, as always, don't take my word for it but also look it up in the BOL. Search for differential backups, it also suggests some strategies.

Hope this helps.|||Sweet!

It makes sense now.

BACKUP DATABASE 'mydb' TO DISK = N'D:\MSSQL\Backups\mydb.bak' WITH INIT , NOUNLOAD , DIFFERENTIAL

This is it right? Then I scheduled it to run nightly.

Thanks for your help!|||This way you're effectively overwriting (WITH INIT) the previous backup. Make sure that one is securely on the tape!

We always put a date, time and backup type in the file name so we can tell them apart and order them easily. But that's a matter of choice.

Before committing to this solution I recommend doing some tests with backing up and restoring this way (not on you production environment!). You will get a feel for doing it and if you document along the way you'll have your emergeny backup plan 75% finished :cool:

Afterwards make it a point to test restoring (tape to disk to SQL Server) once every few months to check if everything is still in working order (believe me, I've experienced tape units merrily messing up backups for month without the slightest hickup).

Have fun! :D

BTW. NOUNLOAD works only for tape backups.

Wednesday, March 7, 2012

different searches for web matrix and sql server

Hi Everyone. I have created a procedure on sql to obtain information about two tables ( bookinfo and author). The procedure is :

CREATE PROCEDURE FindBookByAuthor
@.Aname char
AS

select b.libcode, b.title, b.subject, a.authorname, b.instock
from bookinfo b join authorinfo a
on b.authorid = a.authorid
where a.authorname like '%' + @.aname + '%'
GO

I have tested this procedure changing the variable @.aname for the surname of the author. This works fine. The problem comes when I execute this procedure from web matrix. I use a textbox to obtain the data for the variable @.aname. I send the data. What happens is that when I run the web page and look for a book through the author the select statement behaves differently and gives me a different output.

I would be glad to know why this happens

ThanksShow some code. Failing that, verify in SQL Profiler that the SQL/Parameters you think you are executing is in fact what is being executed.|||well, the asp.net code is :
--------------------


Sub Button2_Click(sender As Object, e As EventArgs)
Dim objConn As SqlConnection
Dim dataReader As SqlDataReader
dim constring as string
Dim objCmd As SqlCommand
constring = "server='(local)'; trusted_connection=true; database='dbjaime'"
objConn = New sqlconnection(constring)
dim strsql as string
strsql = "EXECUTE findtitle '" & textboxtitle.text & "'"
objCmd = New SqlCommand(strSQL, objConn)

objConn.Open()
dataReader = objCmd.ExecuteReader()
'Bind to DataGrid
dtgbooks.DataSource = dataReader
dtgbooks.DataBind()

objConn.Close()
objConn.Dispose()
End Sub
--------------------


Where "findtitle" is a procedure I showed you before.|||Use SQL Profiler and see if what you are sending is what you think you are in both cases (where it works and where it does not).|||I have tried to use the sql profiler, which I had never used before. It shows me the last executions. Then I have loaded my web page and execute the event "button click" I send you before. Now what I see on the sql profile is:

exec sp_executesql N'EXECUTE findtitle ''design'''

among other stuff. I this what I should get?|||The findtitle line is what I was having you look for.

Execute the code in the way that it works, as well as the way that it does not work, and compare what appears in SQL Profiler. You are saying running the code with Web Matrix produces different results. I am looking to have you isolate exactly why the results are different.|||ok. I'll take a look. Thanks for being so quick.|||I'm not sure if I'm passing the parameters correctly to the procedure findtitle on the line:

strsql = "EXECUTE findtitle ' " & txt1.text & " ' "

I say that they give me different results because when I copy the select statement from the procedure into the SQL analyzer I subtitute the variabe @.btitle for a word such as 'database'. And then, when I execute the web page I insert in the textbox the word database.

am I doing something wrong?

Thanks