473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Restoring logs to a database

Hi Gurus,

i am having problems with restoring a ms sql database.

i have restored the database using veritas to a different location
('g:\datafiles') in no recover mode.

when i view the database through the Enterprise Manager, it shows the
database as silver icon (loading).

i go to sql analyzer, and put in the restore command

restore log myDatabase
from 'mylog'
with recovery

this produces an error

RESTORE FILELISTONLY
FROM jobs

Server: Msg 3206, Level 16, State 1, Line 1
No entry in sysdevices for backup device 'mylog'. Update sysdevices
and rerun
statement.

i look in master..sysdevices - no entry for mylog, but then no entries
for the log files for any of the other perfectly working databases
either.

i do have a copy of the log files ('c:\logfiles') in another location

i would like the following help if possible:

* a way to update sysdevices with the log file i wish to apply to my
restored database so it will let my restore go through properly.

* a way to specify to use apply the logs in 'c:\logfiles' without
having to give the restore statement a logical name for the log files
(which naturally won't be in sysdevices!)

pls supply transact sql

my thanks

Edwina63

(if wish to email please remove h from edwinah@)

p.s sp_add_log_file_recover_suspect_db will not work in a partially
restored database
Jul 20 '05 #1
6 9577
> * a way to specify to use apply the logs in 'c:\logfiles' without
having to give the restore statement a logical name for the log files
(which naturally won't be in sysdevices!)

pls supply transact sql
You can specify the DISK parameter. For example.

RESTORE LOG myDatabase
FROM DISK='c:\logfiles\myDatabaseLogBackup1.bak'
WITH NORECOVERY

RESTORE LOG myDatabase
FROM DISK='c:\logfiles\myDatabaseLogBackup2.bak'
WITH RECOVERY

--
Hope this helps.

Dan Guzman
SQL Server MVP

-----------------------
SQL FAQ links (courtesy Neil Pike):

http://www.ntfaq.com/Articles/Index....partmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
-----------------------

"Edwinah63" <ed*****@customercare.com.au> wrote in message
news:d7**************************@posting.google.c om... Hi Gurus,

i am having problems with restoring a ms sql database.

i have restored the database using veritas to a different location
('g:\datafiles') in no recover mode.

when i view the database through the Enterprise Manager, it shows the
database as silver icon (loading).

i go to sql analyzer, and put in the restore command

restore log myDatabase
from 'mylog'
with recovery

this produces an error

RESTORE FILELISTONLY
FROM jobs

Server: Msg 3206, Level 16, State 1, Line 1
No entry in sysdevices for backup device 'mylog'. Update sysdevices
and rerun
statement.

i look in master..sysdevices - no entry for mylog, but then no entries
for the log files for any of the other perfectly working databases
either.

i do have a copy of the log files ('c:\logfiles') in another location

i would like the following help if possible:

* a way to update sysdevices with the log file i wish to apply to my
restored database so it will let my restore go through properly.

* a way to specify to use apply the logs in 'c:\logfiles' without
having to give the restore statement a logical name for the log files
(which naturally won't be in sysdevices!)

pls supply transact sql

my thanks

Edwina63

(if wish to email please remove h from edwinah@)

p.s sp_add_log_file_recover_suspect_db will not work in a partially
restored database

Jul 20 '05 #2
Hi Dan,

thanks for your reply.

my question was probably not clear enough re applying a spcified file.

we want to do a point in time recovery after a massive crash and have
no backup of the logs, just copies of the current log in

'c:\logfiles\mylog.ldf'

what i need is a transact sql statement where i can apply the *.ldf
file (not a *.bak or *.dat file) to tables restored from last night's
backup.

regards

Edwina
Jul 20 '05 #3
As long as you are using the FULL or BULK_LOGGED recovery model in SQL
2000, you can still backup the log with NO_TRUNCATE even if the database
is marked suspect due to inaccessible data files. This log backup can
be applied to your restored database as long as you didn't perform any
log backups since the database backup.

I'm not sure what steps you've taken so far in your recovery but you may
be able to backup your orphaned log file as outlined in the script
below. It seems you've already done step 6.

/*
1) create a new database with FULL model
2) delete data and log files
3) copy your log file to same name as deleted log file above
4) backup the log with NO_TRUNCATE
5) delete the log file
6) restore original database with NORECOVERY
7) restore log with MOVE and RECOVERY
*/

-- 1) create a new database with FULL model
USE master
GO
CREATE DATABASE RecoverLog
ON(NAME='RecoverLog',
FILENAME='C:\RecoverLog.mdf')
LOG ON(NAME='RecoverLog_Log',
FILENAME='C:\RecoverLog_Log.ldf')
GO
ALTER DATABASE RecoverLog
SET RECOVERY FULL
GO
EXEC sp_dboption 'RecoverLog', 'autoclose', true
GO

-- 2) delete data and log files
EXEC master..xp_cmdshell 'del C:\RecoverLog.mdf'
EXEC master..xp_cmdshell 'del C:\RecoverLog_Log.ldf'
GO

-- 3) copy your log file to C:\RecoverLog_Log.ldf'
EXEC master..xp_cmdshell 'copy c:\logfiles\mylog.ldf
C:\RecoverLog_Log.ldf'
GO

-- 4) backup the log with NO_TRUNCATE
-- Note that backup will error due to inaccessible data file
-- but log will still be backed up.
BACKUP LOG RecoverLog
TO DISK='C:\Backups\RecoverLog.bak'
WITH NO_TRUNCATE, INIT
GO

DROP DATABASE RecoverLog
GO

-- 5) delete the log file
EXEC master..xp_cmdshell 'del C:\RecoverLog_Log.ldf'
GO

-- 6) restore original database with NORECOVERY
RESTORE DATABASE MyDatabase
FROM DISK='C:\Backups\MyDatabase.bak'
WITH NORECOVERY
GO

-- 7) restore log with MOVE and RECOVERY
RESTORE LOG MyDatabase
FROM DISK='C:\Backups\RecoverLog.bak'
WITH MOVE 'RecoverLog_Log' TO 'C:\MyDatabase_Log.ldf',
RECOVERY
GO

--
Hope this helps.

Dan Guzman
SQL Server MVP

-----------------------
SQL FAQ links (courtesy Neil Pike):

http://www.ntfaq.com/Articles/Index....partmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
-----------------------

"Edwinah63" <ed*****@customercare.com.au> wrote in message
news:d7**************************@posting.google.c om...
Hi Dan,

thanks for your reply.

my question was probably not clear enough re applying a spcified file.

we want to do a point in time recovery after a massive crash and have
no backup of the logs, just copies of the current log in

'c:\logfiles\mylog.ldf'

what i need is a transact sql statement where i can apply the *.ldf
file (not a *.bak or *.dat file) to tables restored from last night's
backup.

regards

Edwina

Jul 20 '05 #4

"Edwinah63" <ed*****@customercare.com.au> wrote in message
news:d7**************************@posting.google.c om...
Hi Dan,

thanks for your reply.

my question was probably not clear enough re applying a spcified file.

we want to do a point in time recovery after a massive crash and have
no backup of the logs, just copies of the current log in

'c:\logfiles\mylog.ldf'

what i need is a transact sql statement where i can apply the *.ldf
file (not a *.bak or *.dat file) to tables restored from last night's
backup.
I don't believe this is possible.

You'll probably have to open a case with Microsoft tech support.


regards

Edwina

Jul 20 '05 #5
Hi Dan,

"Hope this helps" ?

it most certainly does!!

thank you for taking the time to post such a comprehensive reply. as
it happens i have spent the day researching a restore methodology
which is fairly similar to the one you have recommended, so it is good
to see my logic corroborated by someone else.

all of this came about because of a huge crash we had yesterday
afternoon and it took us approx 10 hours to fix.

many many thanks

Edwinah63
Jul 20 '05 #6
Glad it helped. It pays to practice your disaster recovery plan under a
variety of scenarios so that you have confidence in your DR procedures.
Like Greg mentioned, you can always call Microsoft PSS if you find
yourself in a bind.

--
Dan Guzman
SQL Server MVP
"Edwinah63" <ed*****@customercare.com.au> wrote in message
news:d7**************************@posting.google.c om...
Hi Dan,

"Hope this helps" ?

it most certainly does!!

thank you for taking the time to post such a comprehensive reply. as
it happens i have spent the day researching a restore methodology
which is fairly similar to the one you have recommended, so it is good
to see my logic corroborated by someone else.

all of this came about because of a huge crash we had yesterday
afternoon and it took us approx 10 hours to fix.

many many thanks

Edwinah63

Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Vincento Harris | last post by:
Sqlserver 2000 windows 2003 server Database is backed up and restored on a new server with all transaction logs present . Need help with a script to restore database to a a point in time ...
1
by: M&M | last post by:
Dear All, Do anyone know where I can find some useful documentation or any documentation about restoring database to the point in time (using logs). SQL Server 2000 on Win 2000 Thanks for...
2
by: p175 | last post by:
Hi folks, I've tried reading just about every post I can on raid stiping / extent size etc and I'm just getting myself more confused than ever. Here's my situation. On a Windows Server 2000...
1
by: Robbert van Geldrop | last post by:
Hello, I have a problem restoring Exchange 2000 files. Our software has an interface to ESEBCLI2.dll for online backup and restore features. Everything works fine with Exchange 2003 and also...
0
by: DUG | last post by:
There is a server in a remote location. We receive a full .bak of this database to restore on our server, where we use the data for a seperate purpose. The .BAK file is almost 3GB - zipped! They...
5
by: Troels Arvin | last post by:
Hello, Every so often, I'm asked to help people recover data from tables that were either dropped or where to much data was DELETEed. The complications related to restoring data are a problem....
1
by: GM | last post by:
We have received a backup file that is 6G in size. The log file is about 74G while the MDF is about 5 G when we restored. Is there a way to run a SQL script to restore the .BAK file without...
2
by: l0b0 | last post by:
I'm working on a restore procedure for the case where all MDF files are missing, but the LDF files are all intact. A full backup is done every 24 hours, and a log backup is done every 3 hours....
2
by: KeithWalton | last post by:
I know this has been discussed before, but my database is getting huge. Every night I restore backups of my databases to a report server. I don't need the logs, so after restore I detach the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.