Tuesday, March 20, 2012
Backup device
is there a stored procedure which allows me to query if there is an existing backup device? or which gives me a listing of existing backup devices?
Thanks!SP_HELPDEVICE and in SQL 2K this is used for backward compatibility with earlier versions of SQL Server.
Refer to books online for more information.|||Thanx Satya. Appreciate.
Monday, March 19, 2012
Backup Database! this is really interesting!
I run this in query analyzer
dump database MYDB to disk = 'c:\temp.dat' with init
sql server fails to back up and returns
Server: Msg 3202, Level 16, State 1, Line 1
Write on 'c:\temp.dat' failed, status = 64. See the SQL Server Error Log For
More details.
Server: Msg 3013, Level 16, State 1, Line 1
Backup Database is terminating abnormally
and these are the diagnostics and computer configurations i
performed(computerA):
1. There is 25.5 GB of free space available on C drive.
2. The computer has two RAIDSone SCSI drive. It generates same error on all
of them. This leads me to believe that this is not hardware problem.
3. It generates for all three databases on the server. so not dependent on
database either.
4. Tested on another computer with same hardware but got the databases from
computerA. It fails on that computer too.
5. tested on yet another computer with older versions of the same databases
,(not restored from computerA). It succeeds.
My thoughts are inclined towards virus or sth in the database. but here
comes the kicker. asked the services guy to send me the database backups.
Restored dbs on my machine to the backup copies. It all works fine.
So not the DBs, Not the SQL Server, not the Hardware. what is it?
Or am i totally on the wrong track?
Please someone put some suggestions. I am burning saturday to do this.
A couple things to note. One is that DUMP is the old 6.5 command and you
should be using BACKUP DATABASE instead. But I suspect the error is due to
incorrect permissions but without more details it's hard to say for sure.
Did you check the SQL Error log as it stated? The backup command is always
done under the account SQL Server is running under. So make sure that
account has write permissions on that directory and file. Make sure the file
is not locked by some other application such as a tape backup process.
Andrew J. Kelly SQL MVP
"venAdder" <venAdder@.discussions.microsoft.com> wrote in message
news:F7183062-C942-4B7C-8DD3-A0FAC0228CC8@.microsoft.com...
> Hi,
> I run this in query analyzer
> dump database MYDB to disk = 'c:\temp.dat' with init
> sql server fails to back up and returns
> Server: Msg 3202, Level 16, State 1, Line 1
> Write on 'c:\temp.dat' failed, status = 64. See the SQL Server Error Log
> For
> More details.
> Server: Msg 3013, Level 16, State 1, Line 1
> Backup Database is terminating abnormally
>
> and these are the diagnostics and computer configurations i
> performed(computerA):
> 1. There is 25.5 GB of free space available on C drive.
> 2. The computer has two RAIDSone SCSI drive. It generates same error on
> all
> of them. This leads me to believe that this is not hardware problem.
> 3. It generates for all three databases on the server. so not dependent on
> database either.
> 4. Tested on another computer with same hardware but got the databases
> from
> computerA. It fails on that computer too.
> 5. tested on yet another computer with older versions of the same
> databases
> ,(not restored from computerA). It succeeds.
> My thoughts are inclined towards virus or sth in the database. but here
> comes the kicker. asked the services guy to send me the database backups.
> Restored dbs on my machine to the backup copies. It all works fine.
> So not the DBs, Not the SQL Server, not the Hardware. what is it?
> Or am i totally on the wrong track?
> Please someone put some suggestions. I am burning saturday to do this.
|||I am sorry c:\temp.dat is wrong.
it is \\myserver\c$\temp.dat
Ok I think I know what the problem is. The path is actually
'\\myserver\c$\temp.dat'. The status = 64 means The specified network name
is no longer available ( ERROR_NETNAME_DELETED ). But the myserver is the
name of the computer on which sql server runs. I mean sql server is installed
on myserver. So it should be same as saying c:\temp.dat.
So the query becomes
dump database MYDB to disk = '\\myserver\c$\temp.dat' with init
But in case of c:\temp.dat it succeeds and in case of \\myserver\c$\temp.dat
it fails ( it used to work, but has been failing recently).
Now i tried following.
1. I am able to access c drive on myserver by typing \\myserver\c$ in
windows explorer from another computer on LAN.
2. I am able to access c drive by typing \\myserver\c$ in the windows
explorer on myserver.
3. ping 127.0.0.1 return normal results on myserver.
So why does windows generates ERROR_NETNAME_DELETED when i run
dump database MYDB to disk = '\\myserver\c$\temp.dat' with init
in query analyzer?
|||If this is duplicate sorry, for some reason i don't see my posts on the forum
Ok I think I know what the problem is. Sorry for the 'c:\temp.dat'. The path
is actually
'\\myserver\c$\temp.dat'. The status = 64 means The specified network name
is no longer available ( ERROR_NETNAME_DELETED ). But the myserver is the
name of the computer on which sql server runs. I mean sql server is installed
on myserver. So it should be same as saying c:\temp.dat.
So the query becomes
dump database MYDB to disk = '\\myserver\c$\temp.dat' with init
But in case of c:\temp.dat it succeeds and in case of \\myserver\c$\temp.dat
it fails ( it used to work, but ahs been failing recently).
Now i tried following.
1. I am able to access c drive on myserver by typing \\myserver\c$ in
windows explorer from another computer on LAN.
2. I am able to access c drive by typing \\myserver\c$ in the windows
explorer on myserver.
3. ping 127.0.0.1 return normal results on myserver.
So why does windows generates ERROR_NETNAME_DELETED when i run
dump database MYDB to disk = '\\myserver\c$\temp.dat' with init
in query analyzer?
|||I think Andrew is correct that it is a permissions issue. It works fine
locally on my machine.
Try this from Query Analyzer:
exec master..xp_cmdshell 'dir \\myserver\c$\temp.dat'
You should see the output of the dir command in the results pane.
Ron
Ron Talmage
SQL Server MVP
"venAdder" <venAdder@.discussions.microsoft.com> wrote in message
news:4AFC6143-1BC2-483C-AB63-DB4AFD398EE6@.microsoft.com...
> If this is duplicate sorry, for some reason i don't see my posts on the
forum
> Ok I think I know what the problem is. Sorry for the 'c:\temp.dat'. The
path
> is actually
> '\\myserver\c$\temp.dat'. The status = 64 means The specified network name
> is no longer available ( ERROR_NETNAME_DELETED ). But the myserver is the
> name of the computer on which sql server runs. I mean sql server is
installed
> on myserver. So it should be same as saying c:\temp.dat.
> So the query becomes
> dump database MYDB to disk = '\\myserver\c$\temp.dat' with init
> But in case of c:\temp.dat it succeeds and in case of
\\myserver\c$\temp.dat
> it fails ( it used to work, but ahs been failing recently).
> Now i tried following.
> 1. I am able to access c drive on myserver by typing \\myserver\c$ in
> windows explorer from another computer on LAN.
> 2. I am able to access c drive by typing \\myserver\c$ in the windows
> explorer on myserver.
> 3. ping 127.0.0.1 return normal results on myserver.
>
> So why does windows generates ERROR_NETNAME_DELETED when i run
> dump database MYDB to disk = '\\myserver\c$\temp.dat' with init
> in query analyzer?
>
|||I still think it is permissions. Log on to the server with the account that
SQL Server is running under and see if you can access that share.
Andrew J. Kelly SQL MVP
"venAdder" <venAdder@.discussions.microsoft.com> wrote in message
news:B3D7FA16-1D79-48BF-8D64-90319A6A9B7C@.microsoft.com...
>I am sorry c:\temp.dat is wrong.
> it is \\myserver\c$\temp.dat
> Ok I think I know what the problem is. The path is actually
> '\\myserver\c$\temp.dat'. The status = 64 means The specified network name
> is no longer available ( ERROR_NETNAME_DELETED ). But the myserver is the
> name of the computer on which sql server runs. I mean sql server is
> installed
> on myserver. So it should be same as saying c:\temp.dat.
> So the query becomes
> dump database MYDB to disk = '\\myserver\c$\temp.dat' with init
> But in case of c:\temp.dat it succeeds and in case of
> \\myserver\c$\temp.dat
> it fails ( it used to work, but has been failing recently).
> Now i tried following.
> 1. I am able to access c drive on myserver by typing \\myserver\c$ in
> windows explorer from another computer on LAN.
> 2. I am able to access c drive by typing \\myserver\c$ in the windows
> explorer on myserver.
> 3. ping 127.0.0.1 return normal results on myserver.
>
> So why does windows generates ERROR_NETNAME_DELETED when i run
> dump database MYDB to disk = '\\myserver\c$\temp.dat' with init
> in query analyzer?
>
>
|||No it's not a permissions issue. The reason is when that query executes i can
see the file in explorer for a few seconds. Then it gets deleted when query
fails. Here is what happened:
The issue turned out to be network redirector cahing related.
The precise article corressponding to this is
http://support.microsoft.com/default...EN-US;q285997.
The reason I am sure this is it because the articles describes that using
c:\ should
be fine, which is actually the case. It works fine if no unc is used. and
the windows reports this failed to write to
\device\lanmanredirector\........... it's exactly the error described in
that article.
the solution to this is here
http://support.microsoft.com/default...b;en-us;163401
Now this article explains how to turn off network redirector disabling in
winnt not in win 2000. I opened win registry. The keys are diff.
does anyone know how to do the same thing in win2000professional?
and also it's still a mystry what could ahve caused this problem on that
particular computer. The file size might be one of the causes, but I don't
think so because I have tried on computers configured in exactly the same
way(hardware and software) with much larger files and it all works fine.
|||Make sure your WORKSTATION has the Server Service and the RPC Service
running.
Sincerely,
Anthony Thomas
"venAdder" <venAdder@.discussions.microsoft.com> wrote in message
news:057130BB-486B-4092-AED3-5B24680AD800@.microsoft.com...
No it's not a permissions issue. The reason is when that query executes i
can
see the file in explorer for a few seconds. Then it gets deleted when query
fails. Here is what happened:
The issue turned out to be network redirector cahing related.
The precise article corressponding to this is
http://support.microsoft.com/default...EN-US;q285997.
The reason I am sure this is it because the articles describes that using
c:\ should
be fine, which is actually the case. It works fine if no unc is used. and
the windows reports this failed to write to
\device\lanmanredirector\........... it's exactly the error described in
that article.
the solution to this is here
http://support.microsoft.com/default...b;en-us;163401
Now this article explains how to turn off network redirector disabling in
winnt not in win 2000. I opened win registry. The keys are diff.
does anyone know how to do the same thing in win2000professional?
and also it's still a mystry what could ahve caused this problem on that
particular computer. The file size might be one of the causes, but I don't
think so because I have tried on computers configured in exactly the same
way(hardware and software) with much larger files and it all works fine.
Sunday, March 11, 2012
Backup database aborts job in the agent, but not when in a query window
Does anyone know why a backup database statement aborts a job in a stored procedure so that you can't handle the error with @.@.error, but when you run the same stored procedure in a query window the error handling does get run?
The snippet of code looks like this:
SET XACT_ABORT OFF
SET ANSI_NULLS OFF
set ansi_warnings off
set arithabort on
declare @.backup_status int
declare @.cmd varchar(1024)
SET NOCOUNT ON
print 'Options value: ' + convert(varchar, @.@.options)
set @.backup_status = 0
if (@.backup_mode = 'F')
begin
BACKUP DATABASE
@.DB TO DISK = @.BackupFile
with
NAME = @.Name,
DESCRIPTION = @.Description,
MEDIANAME = @.MediaName,
MEDIADESCRIPTION = @.Description,
STATS = 10,
init, nounload, noskip
if @.@.error != 0
begin
set @.backup_status = 1
print '**************** Backup of ' + @.DB + ' Failed'
end end
When this is run in a query window, the print statement at the bottom does get executed, but when run as a step in a sql agent job it does not.
Thanks.
As an additional comment, this doesn't seem to happen on my SQL 2000 server, just the SQL 2005 sp1 server.Backup Database
BACKUP DATABASE my_database
TO DISK 'C:\backups\my_database.bak'
WITH FORMAT
GO
and send me this error
Cannot open backup device 'C:\backups\my_database.bak'. Operating system error 3 (error not found)
BACKUP DATABASE is terminating abnormally
Please help me
Regardstry this
BACKUP DATABASE abc
TO DISK='C:\backups\abc.bak'
WITH FORMAT
GO
Quote:
Originally Posted by japuentem
I want to backup a database with the SQL Query Analizer with the following instruction:
BACKUP DATABASE my_database
TO DISK 'C:\backups\my_database.bak'
WITH FORMAT
GO
and send me this error
Cannot open backup device 'C:\backups\my_database.bak'. Operating system error 3 (error not found)
BACKUP DATABASE is terminating abnormally
Please help me
Regards
Quote:
Originally Posted by bharadwaj
try this
BACKUP DATABASE abc
TO DISK='C:\backups\abc.bak'
WITH FORMAT
GO
I think the problem is because the database is not in the local server, i have the database in a remote server
Thursday, March 8, 2012
Backup check
I want to create a stored procedure to
check if backups ended successfully at remote databases.
Which query can i run?
Many Thanks in Advance,
Galit.Gal
Assuming you are running your backups as jobs. The
information you need should be on sysjobhistory on the
msdb database. You can write a stored procedure to get the
information from there.
Regards
John