Recovering a SQL Server databaseSQL Server 2008 can't repair consistencyDirectory lookup failed during log...
How can I prevent an oracle who can see into the past from knowing everything that has happened?
"I showed the monkey himself in the mirror". Why is this sentence grammatical?
Rigorous justification for non-relativistic QM perturbation theory assumptions?
Do we still track damage on indestructible creatures?
my cron command doesn’t work
Sensor logger for Raspberry Pi in a stratospheric probe
Is Screenshot Time-tracking Common?
Co-worker sabotaging/undoing my work. (Software Development)
Can I travel from country A to country B to country C without going back to country A?
Is there a non trivial covering of the Klein bottle by the Klein bottle
How much light is too much?
Is it legal to point a domain to someone else's ip (website)?
Where does documentation like business and software requirement spec docs fit in an agile project?
Plausible reason for gold-digging ant
What does からか mean?
Was Claire Dearing blamed for any of Jurassic World's failings?
Democratic Socialism vs Social Democracy
"Starve to death" Vs. "Starve to the point of death"
Isn't a semicolon (';') needed after a function declaration in C++?
What are some ways of extending a description of a scenery?
Should a new user just default to LinearModelFit (vs Fit)
How can I deduce the power of a capacitor from its datasheet?
How can I give a Ranger advantage on a check due to Favored Enemy without spoiling the story for the player?
Does the US government have any planning in place to ensure there's no shortages of food, fuel, steel and other commodities?
Recovering a SQL Server database
SQL Server 2008 can't repair consistencyDirectory lookup failed during log shippingAttempting to restore SQL Server 2005 database to a SQL Server 2008 R2 instance gives reason: 15105 errorHelp in Automating Database Restoration in SQL ServerFailed to update SQL Server 2008 R2 RTM to SP3Suddenly cannot access SQL Server databaseRestoring Database, creating new copy and use existing transaction logs for the original backup database to restore the NEW database to be current?Database mirroring, “WITH NORECOVERY”How to recover if SQL Server is stuck in Restoring state?SQL Server error “Missing family sequence number 2”
In a series of unfortunate mistakes, I managed to lose 4 months of data and rapid database modifications. I’m not a database administrator, I’m a programmer that also designs and maintains a database.
I initially just wanted to only compare some database objects to another database. I did that using OpenDBDiff tool. I selected the objects that I wanted to update and hit ‘Update selected’. It failed for some reason, but I didn’t pay attention. So I generated a script to execute directly into SSMS. I again failed to notice that the script included all objects, not just the selected. I realized that too late, some of the destination's database tables, views, functions, etc. were dropped.
And then it got worse. I know we have daily backup and decided to restore for it. It turns out that for some reason, this database, on that server has its last backup from 4 months ago. I decided that I’ll restore from it and its transaction log to the current date. I still don’t know if that’s even possible, but I decided to do it on a live database. I did not take a new backup at this point, I was afraid that this will destroy the transaction log. So I ran a command like this:
USE [master]
BACKUP LOG [mydb] TO DISK = N'C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLBackupmydb_LogBackup_2019-01-17_13-49-00.bak' WITH NOFORMAT, NOINIT, NAME = N'mydb_LogBackup_2019-01-17_13-49-00', NOSKIP, NOREWIND, NOUNLOAD, NORECOVERY , STATS = 5
RESTORE DATABASE [mydb] FROM DISK = N'D:Backupsmydb_2018_08_30_19_01_01mydb.bak' WITH FILE = 1, MOVE N'exact_Data' TO N'C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLDATAmydb.mdf', MOVE N'exact_Log' TO N'C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLDATAmydb.ldf', NORECOVERY, NOUNLOAD, STATS = 5
RESTORE LOG [mydb] FROM DISK = N'C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLBackupmydb_LogBackup_2019-01-17_13-49-00.bak' WITH NOUNLOAD, STATS = 5, STOPAT = N'2019-01-17T13:00:00'
GO
The log backup failed. The database is now in restoring state. Before all this, mydb.mdf and mydb.ldf files where located in the D:db
folder, now they are not there. Instead they are in C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLDATA
. I tried to attach them to my local server, it fails because they are in restoring state too. I download and managed to open the with a SQL Server database repair tool, but the only hold the data from 4 months ago.
I’m currently scanning the computer for deleted files to search for the original .mdf and .ldf files, but I don’t have much hope on this because the quick scan didn’t show anything and I’m running a deep scan now.
Questions
How can I take the database out of that (restoring…) state and what will happen if I do so? This is why I decided to ask before I do one more unconvenient thing.
My end goal is to restore the database in the most recent possible state, so how can I achieve that?
sql-server sql-server-2008-r2
add a comment |
In a series of unfortunate mistakes, I managed to lose 4 months of data and rapid database modifications. I’m not a database administrator, I’m a programmer that also designs and maintains a database.
I initially just wanted to only compare some database objects to another database. I did that using OpenDBDiff tool. I selected the objects that I wanted to update and hit ‘Update selected’. It failed for some reason, but I didn’t pay attention. So I generated a script to execute directly into SSMS. I again failed to notice that the script included all objects, not just the selected. I realized that too late, some of the destination's database tables, views, functions, etc. were dropped.
And then it got worse. I know we have daily backup and decided to restore for it. It turns out that for some reason, this database, on that server has its last backup from 4 months ago. I decided that I’ll restore from it and its transaction log to the current date. I still don’t know if that’s even possible, but I decided to do it on a live database. I did not take a new backup at this point, I was afraid that this will destroy the transaction log. So I ran a command like this:
USE [master]
BACKUP LOG [mydb] TO DISK = N'C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLBackupmydb_LogBackup_2019-01-17_13-49-00.bak' WITH NOFORMAT, NOINIT, NAME = N'mydb_LogBackup_2019-01-17_13-49-00', NOSKIP, NOREWIND, NOUNLOAD, NORECOVERY , STATS = 5
RESTORE DATABASE [mydb] FROM DISK = N'D:Backupsmydb_2018_08_30_19_01_01mydb.bak' WITH FILE = 1, MOVE N'exact_Data' TO N'C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLDATAmydb.mdf', MOVE N'exact_Log' TO N'C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLDATAmydb.ldf', NORECOVERY, NOUNLOAD, STATS = 5
RESTORE LOG [mydb] FROM DISK = N'C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLBackupmydb_LogBackup_2019-01-17_13-49-00.bak' WITH NOUNLOAD, STATS = 5, STOPAT = N'2019-01-17T13:00:00'
GO
The log backup failed. The database is now in restoring state. Before all this, mydb.mdf and mydb.ldf files where located in the D:db
folder, now they are not there. Instead they are in C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLDATA
. I tried to attach them to my local server, it fails because they are in restoring state too. I download and managed to open the with a SQL Server database repair tool, but the only hold the data from 4 months ago.
I’m currently scanning the computer for deleted files to search for the original .mdf and .ldf files, but I don’t have much hope on this because the quick scan didn’t show anything and I’m running a deep scan now.
Questions
How can I take the database out of that (restoring…) state and what will happen if I do so? This is why I decided to ask before I do one more unconvenient thing.
My end goal is to restore the database in the most recent possible state, so how can I achieve that?
sql-server sql-server-2008-r2
Unfortunately, in current circumstances, imho, it will be not possible to restore a database to a state more recent than that four month old backup. There is only one hope that that backup is not initialized every day and it contains more than one backup set
– Alexandr Volok
Jan 17 at 20:05
1
Can you execute: “restore headeronly from disk=‘path-to-backup’”. How many rows it returns?
– Alexandr Volok
Jan 17 at 20:08
add a comment |
In a series of unfortunate mistakes, I managed to lose 4 months of data and rapid database modifications. I’m not a database administrator, I’m a programmer that also designs and maintains a database.
I initially just wanted to only compare some database objects to another database. I did that using OpenDBDiff tool. I selected the objects that I wanted to update and hit ‘Update selected’. It failed for some reason, but I didn’t pay attention. So I generated a script to execute directly into SSMS. I again failed to notice that the script included all objects, not just the selected. I realized that too late, some of the destination's database tables, views, functions, etc. were dropped.
And then it got worse. I know we have daily backup and decided to restore for it. It turns out that for some reason, this database, on that server has its last backup from 4 months ago. I decided that I’ll restore from it and its transaction log to the current date. I still don’t know if that’s even possible, but I decided to do it on a live database. I did not take a new backup at this point, I was afraid that this will destroy the transaction log. So I ran a command like this:
USE [master]
BACKUP LOG [mydb] TO DISK = N'C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLBackupmydb_LogBackup_2019-01-17_13-49-00.bak' WITH NOFORMAT, NOINIT, NAME = N'mydb_LogBackup_2019-01-17_13-49-00', NOSKIP, NOREWIND, NOUNLOAD, NORECOVERY , STATS = 5
RESTORE DATABASE [mydb] FROM DISK = N'D:Backupsmydb_2018_08_30_19_01_01mydb.bak' WITH FILE = 1, MOVE N'exact_Data' TO N'C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLDATAmydb.mdf', MOVE N'exact_Log' TO N'C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLDATAmydb.ldf', NORECOVERY, NOUNLOAD, STATS = 5
RESTORE LOG [mydb] FROM DISK = N'C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLBackupmydb_LogBackup_2019-01-17_13-49-00.bak' WITH NOUNLOAD, STATS = 5, STOPAT = N'2019-01-17T13:00:00'
GO
The log backup failed. The database is now in restoring state. Before all this, mydb.mdf and mydb.ldf files where located in the D:db
folder, now they are not there. Instead they are in C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLDATA
. I tried to attach them to my local server, it fails because they are in restoring state too. I download and managed to open the with a SQL Server database repair tool, but the only hold the data from 4 months ago.
I’m currently scanning the computer for deleted files to search for the original .mdf and .ldf files, but I don’t have much hope on this because the quick scan didn’t show anything and I’m running a deep scan now.
Questions
How can I take the database out of that (restoring…) state and what will happen if I do so? This is why I decided to ask before I do one more unconvenient thing.
My end goal is to restore the database in the most recent possible state, so how can I achieve that?
sql-server sql-server-2008-r2
In a series of unfortunate mistakes, I managed to lose 4 months of data and rapid database modifications. I’m not a database administrator, I’m a programmer that also designs and maintains a database.
I initially just wanted to only compare some database objects to another database. I did that using OpenDBDiff tool. I selected the objects that I wanted to update and hit ‘Update selected’. It failed for some reason, but I didn’t pay attention. So I generated a script to execute directly into SSMS. I again failed to notice that the script included all objects, not just the selected. I realized that too late, some of the destination's database tables, views, functions, etc. were dropped.
And then it got worse. I know we have daily backup and decided to restore for it. It turns out that for some reason, this database, on that server has its last backup from 4 months ago. I decided that I’ll restore from it and its transaction log to the current date. I still don’t know if that’s even possible, but I decided to do it on a live database. I did not take a new backup at this point, I was afraid that this will destroy the transaction log. So I ran a command like this:
USE [master]
BACKUP LOG [mydb] TO DISK = N'C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLBackupmydb_LogBackup_2019-01-17_13-49-00.bak' WITH NOFORMAT, NOINIT, NAME = N'mydb_LogBackup_2019-01-17_13-49-00', NOSKIP, NOREWIND, NOUNLOAD, NORECOVERY , STATS = 5
RESTORE DATABASE [mydb] FROM DISK = N'D:Backupsmydb_2018_08_30_19_01_01mydb.bak' WITH FILE = 1, MOVE N'exact_Data' TO N'C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLDATAmydb.mdf', MOVE N'exact_Log' TO N'C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLDATAmydb.ldf', NORECOVERY, NOUNLOAD, STATS = 5
RESTORE LOG [mydb] FROM DISK = N'C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLBackupmydb_LogBackup_2019-01-17_13-49-00.bak' WITH NOUNLOAD, STATS = 5, STOPAT = N'2019-01-17T13:00:00'
GO
The log backup failed. The database is now in restoring state. Before all this, mydb.mdf and mydb.ldf files where located in the D:db
folder, now they are not there. Instead they are in C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLDATA
. I tried to attach them to my local server, it fails because they are in restoring state too. I download and managed to open the with a SQL Server database repair tool, but the only hold the data from 4 months ago.
I’m currently scanning the computer for deleted files to search for the original .mdf and .ldf files, but I don’t have much hope on this because the quick scan didn’t show anything and I’m running a deep scan now.
Questions
How can I take the database out of that (restoring…) state and what will happen if I do so? This is why I decided to ask before I do one more unconvenient thing.
My end goal is to restore the database in the most recent possible state, so how can I achieve that?
sql-server sql-server-2008-r2
sql-server sql-server-2008-r2
edited Jan 17 at 20:00
Petar Slavov
asked Jan 17 at 19:40
Petar SlavovPetar Slavov
62
62
Unfortunately, in current circumstances, imho, it will be not possible to restore a database to a state more recent than that four month old backup. There is only one hope that that backup is not initialized every day and it contains more than one backup set
– Alexandr Volok
Jan 17 at 20:05
1
Can you execute: “restore headeronly from disk=‘path-to-backup’”. How many rows it returns?
– Alexandr Volok
Jan 17 at 20:08
add a comment |
Unfortunately, in current circumstances, imho, it will be not possible to restore a database to a state more recent than that four month old backup. There is only one hope that that backup is not initialized every day and it contains more than one backup set
– Alexandr Volok
Jan 17 at 20:05
1
Can you execute: “restore headeronly from disk=‘path-to-backup’”. How many rows it returns?
– Alexandr Volok
Jan 17 at 20:08
Unfortunately, in current circumstances, imho, it will be not possible to restore a database to a state more recent than that four month old backup. There is only one hope that that backup is not initialized every day and it contains more than one backup set
– Alexandr Volok
Jan 17 at 20:05
Unfortunately, in current circumstances, imho, it will be not possible to restore a database to a state more recent than that four month old backup. There is only one hope that that backup is not initialized every day and it contains more than one backup set
– Alexandr Volok
Jan 17 at 20:05
1
1
Can you execute: “restore headeronly from disk=‘path-to-backup’”. How many rows it returns?
– Alexandr Volok
Jan 17 at 20:08
Can you execute: “restore headeronly from disk=‘path-to-backup’”. How many rows it returns?
– Alexandr Volok
Jan 17 at 20:08
add a comment |
3 Answers
3
active
oldest
votes
The last successful restore was the RESTORE DATABASE. Since you specified NORECOVERY, the database is, as expected, in restoring state. If you don't have any more backups to restore and just want to get out of the restoring state, you just do:
RESTORE DATABASE mydb WITH RECOVERY
That's it. You find the database as it were when that full backup you restored was produced.
As for log backups, you need an unbroken chain of log backups. You can't skip a log backup, like you most probably tried to do. You likely got an error message saying that the log backup was too recent to restore, citing LSN numbers and that it requires some earlier log backup with some earlier LSN number. There's no way around the "unbroken chain of log backups" requirement. If you can't find those log backups, or a more recent full backup, then you are probably stuck with a 4 month old database.
OK, I understand that. My concern is what happened with the mdf and ldf files that were inD:db
folder - it's empty now? Are they deleted? Can they be somehow recoved?
– Petar Slavov
Jan 17 at 20:14
The restore command will delete the database before it creates the one to restore into (and for that you specified the files to be in the Program Files folder - see the MOVE options for the RESTORE DATABASE command. So, the "old" database files are gone (assuming the files you referred to are those that were used by the database that was overwritten by the RESTORE DATABASE command, of course).
– Tibor Karaszi
Jan 17 at 20:44
Gone means deleted, if so they can be recovered with a recovery tool? I'm running one now, but it's taking too long to scan the drive. I'll wait and report on the results.
– Petar Slavov
Jan 17 at 21:24
add a comment |
You can use the script below to get the backup report.It will help you to locate all the backup. Can you share the result of the query
SELECT msdb.dbo.backupset.database_name,msdb.dbo.backupset.backup_start_date,msdb.dbo.backupset.backup_finish_date,
msdb.dbo.backupset.expiration_date,
CASE msdb..backupset.type
WHEN 'D' THEN 'Database'
WHEN 'L' THEN 'Log'
WHEN 'I' THEN 'Differential'
END AS
backup_type,msdb.dbo.backupset.backup_size,msdb.dbo.backupmediafamily.logical_device_name,
msdb.dbo.backupmediafamily.physical_device_name,msdb.dbo.backupset.name ASbackupset_name,
msdb.dbo.backupset.description
FROM msdb.dbo.backupmediafamily
INNER JOIN msdb.dbo.backupset ON msdb.dbo.backupmediafamily.media_set_id =
msdb.dbo.backupset.media_set_id
WHERE (CONVERT(datetime, msdb.dbo.backupset.backup_start_date,102)) >=cast(GETDATE()-150 AS date)
The result set is 230 rows, there are other database there that have been backed up daily. But the last result formydb
is from the same date as the backup that I restored.
– Petar Slavov
Jan 17 at 21:32
If you don't have any log or differential backups after the full backup then as Tibor said you need to restore the full backup with RECOVERY option. Are there any Log or Diff backups?
– user1716729
Jan 17 at 21:39
add a comment |
I understand that you are not a DBA but like most of us we end up working on projects outside our domain. With that being said; caution should be your number one friend when working in unfamiliar terrorities. Backing up should be your next best friend in such situations. Anyways the harm is already done here and to be honest with you; it will be impossible to get back all the deleted objects if you do not have the correct backup set/chain.
You mentioned you are using a third party database repair tool. I know of one if thats not what you already using called Stellar Database Recovery Toolkit (https://www.stellarinfo.com/sql-recovery.php?gclid=EAIaIQobChMIzci5z4_W4AIVUNbACh1N8ARVEAAYAiAAEgIwCvD_BwE). This can repair corrupted databases and even recovery deleted database objects. The best part is the free trial version has all the features except saving the repaired file. So this is the trick, use the trial and see if the results of recovery is what you looking for. If it is, then viola purchase a full edition with guarantee that you will have your database recovered.
Best of luck and let me know how it goes!
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "182"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f227413%2frecovering-a-sql-server-database%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
The last successful restore was the RESTORE DATABASE. Since you specified NORECOVERY, the database is, as expected, in restoring state. If you don't have any more backups to restore and just want to get out of the restoring state, you just do:
RESTORE DATABASE mydb WITH RECOVERY
That's it. You find the database as it were when that full backup you restored was produced.
As for log backups, you need an unbroken chain of log backups. You can't skip a log backup, like you most probably tried to do. You likely got an error message saying that the log backup was too recent to restore, citing LSN numbers and that it requires some earlier log backup with some earlier LSN number. There's no way around the "unbroken chain of log backups" requirement. If you can't find those log backups, or a more recent full backup, then you are probably stuck with a 4 month old database.
OK, I understand that. My concern is what happened with the mdf and ldf files that were inD:db
folder - it's empty now? Are they deleted? Can they be somehow recoved?
– Petar Slavov
Jan 17 at 20:14
The restore command will delete the database before it creates the one to restore into (and for that you specified the files to be in the Program Files folder - see the MOVE options for the RESTORE DATABASE command. So, the "old" database files are gone (assuming the files you referred to are those that were used by the database that was overwritten by the RESTORE DATABASE command, of course).
– Tibor Karaszi
Jan 17 at 20:44
Gone means deleted, if so they can be recovered with a recovery tool? I'm running one now, but it's taking too long to scan the drive. I'll wait and report on the results.
– Petar Slavov
Jan 17 at 21:24
add a comment |
The last successful restore was the RESTORE DATABASE. Since you specified NORECOVERY, the database is, as expected, in restoring state. If you don't have any more backups to restore and just want to get out of the restoring state, you just do:
RESTORE DATABASE mydb WITH RECOVERY
That's it. You find the database as it were when that full backup you restored was produced.
As for log backups, you need an unbroken chain of log backups. You can't skip a log backup, like you most probably tried to do. You likely got an error message saying that the log backup was too recent to restore, citing LSN numbers and that it requires some earlier log backup with some earlier LSN number. There's no way around the "unbroken chain of log backups" requirement. If you can't find those log backups, or a more recent full backup, then you are probably stuck with a 4 month old database.
OK, I understand that. My concern is what happened with the mdf and ldf files that were inD:db
folder - it's empty now? Are they deleted? Can they be somehow recoved?
– Petar Slavov
Jan 17 at 20:14
The restore command will delete the database before it creates the one to restore into (and for that you specified the files to be in the Program Files folder - see the MOVE options for the RESTORE DATABASE command. So, the "old" database files are gone (assuming the files you referred to are those that were used by the database that was overwritten by the RESTORE DATABASE command, of course).
– Tibor Karaszi
Jan 17 at 20:44
Gone means deleted, if so they can be recovered with a recovery tool? I'm running one now, but it's taking too long to scan the drive. I'll wait and report on the results.
– Petar Slavov
Jan 17 at 21:24
add a comment |
The last successful restore was the RESTORE DATABASE. Since you specified NORECOVERY, the database is, as expected, in restoring state. If you don't have any more backups to restore and just want to get out of the restoring state, you just do:
RESTORE DATABASE mydb WITH RECOVERY
That's it. You find the database as it were when that full backup you restored was produced.
As for log backups, you need an unbroken chain of log backups. You can't skip a log backup, like you most probably tried to do. You likely got an error message saying that the log backup was too recent to restore, citing LSN numbers and that it requires some earlier log backup with some earlier LSN number. There's no way around the "unbroken chain of log backups" requirement. If you can't find those log backups, or a more recent full backup, then you are probably stuck with a 4 month old database.
The last successful restore was the RESTORE DATABASE. Since you specified NORECOVERY, the database is, as expected, in restoring state. If you don't have any more backups to restore and just want to get out of the restoring state, you just do:
RESTORE DATABASE mydb WITH RECOVERY
That's it. You find the database as it were when that full backup you restored was produced.
As for log backups, you need an unbroken chain of log backups. You can't skip a log backup, like you most probably tried to do. You likely got an error message saying that the log backup was too recent to restore, citing LSN numbers and that it requires some earlier log backup with some earlier LSN number. There's no way around the "unbroken chain of log backups" requirement. If you can't find those log backups, or a more recent full backup, then you are probably stuck with a 4 month old database.
answered Jan 17 at 20:08
Tibor KarasziTibor Karaszi
1,8586
1,8586
OK, I understand that. My concern is what happened with the mdf and ldf files that were inD:db
folder - it's empty now? Are they deleted? Can they be somehow recoved?
– Petar Slavov
Jan 17 at 20:14
The restore command will delete the database before it creates the one to restore into (and for that you specified the files to be in the Program Files folder - see the MOVE options for the RESTORE DATABASE command. So, the "old" database files are gone (assuming the files you referred to are those that were used by the database that was overwritten by the RESTORE DATABASE command, of course).
– Tibor Karaszi
Jan 17 at 20:44
Gone means deleted, if so they can be recovered with a recovery tool? I'm running one now, but it's taking too long to scan the drive. I'll wait and report on the results.
– Petar Slavov
Jan 17 at 21:24
add a comment |
OK, I understand that. My concern is what happened with the mdf and ldf files that were inD:db
folder - it's empty now? Are they deleted? Can they be somehow recoved?
– Petar Slavov
Jan 17 at 20:14
The restore command will delete the database before it creates the one to restore into (and for that you specified the files to be in the Program Files folder - see the MOVE options for the RESTORE DATABASE command. So, the "old" database files are gone (assuming the files you referred to are those that were used by the database that was overwritten by the RESTORE DATABASE command, of course).
– Tibor Karaszi
Jan 17 at 20:44
Gone means deleted, if so they can be recovered with a recovery tool? I'm running one now, but it's taking too long to scan the drive. I'll wait and report on the results.
– Petar Slavov
Jan 17 at 21:24
OK, I understand that. My concern is what happened with the mdf and ldf files that were in
D:db
folder - it's empty now? Are they deleted? Can they be somehow recoved?– Petar Slavov
Jan 17 at 20:14
OK, I understand that. My concern is what happened with the mdf and ldf files that were in
D:db
folder - it's empty now? Are they deleted? Can they be somehow recoved?– Petar Slavov
Jan 17 at 20:14
The restore command will delete the database before it creates the one to restore into (and for that you specified the files to be in the Program Files folder - see the MOVE options for the RESTORE DATABASE command. So, the "old" database files are gone (assuming the files you referred to are those that were used by the database that was overwritten by the RESTORE DATABASE command, of course).
– Tibor Karaszi
Jan 17 at 20:44
The restore command will delete the database before it creates the one to restore into (and for that you specified the files to be in the Program Files folder - see the MOVE options for the RESTORE DATABASE command. So, the "old" database files are gone (assuming the files you referred to are those that were used by the database that was overwritten by the RESTORE DATABASE command, of course).
– Tibor Karaszi
Jan 17 at 20:44
Gone means deleted, if so they can be recovered with a recovery tool? I'm running one now, but it's taking too long to scan the drive. I'll wait and report on the results.
– Petar Slavov
Jan 17 at 21:24
Gone means deleted, if so they can be recovered with a recovery tool? I'm running one now, but it's taking too long to scan the drive. I'll wait and report on the results.
– Petar Slavov
Jan 17 at 21:24
add a comment |
You can use the script below to get the backup report.It will help you to locate all the backup. Can you share the result of the query
SELECT msdb.dbo.backupset.database_name,msdb.dbo.backupset.backup_start_date,msdb.dbo.backupset.backup_finish_date,
msdb.dbo.backupset.expiration_date,
CASE msdb..backupset.type
WHEN 'D' THEN 'Database'
WHEN 'L' THEN 'Log'
WHEN 'I' THEN 'Differential'
END AS
backup_type,msdb.dbo.backupset.backup_size,msdb.dbo.backupmediafamily.logical_device_name,
msdb.dbo.backupmediafamily.physical_device_name,msdb.dbo.backupset.name ASbackupset_name,
msdb.dbo.backupset.description
FROM msdb.dbo.backupmediafamily
INNER JOIN msdb.dbo.backupset ON msdb.dbo.backupmediafamily.media_set_id =
msdb.dbo.backupset.media_set_id
WHERE (CONVERT(datetime, msdb.dbo.backupset.backup_start_date,102)) >=cast(GETDATE()-150 AS date)
The result set is 230 rows, there are other database there that have been backed up daily. But the last result formydb
is from the same date as the backup that I restored.
– Petar Slavov
Jan 17 at 21:32
If you don't have any log or differential backups after the full backup then as Tibor said you need to restore the full backup with RECOVERY option. Are there any Log or Diff backups?
– user1716729
Jan 17 at 21:39
add a comment |
You can use the script below to get the backup report.It will help you to locate all the backup. Can you share the result of the query
SELECT msdb.dbo.backupset.database_name,msdb.dbo.backupset.backup_start_date,msdb.dbo.backupset.backup_finish_date,
msdb.dbo.backupset.expiration_date,
CASE msdb..backupset.type
WHEN 'D' THEN 'Database'
WHEN 'L' THEN 'Log'
WHEN 'I' THEN 'Differential'
END AS
backup_type,msdb.dbo.backupset.backup_size,msdb.dbo.backupmediafamily.logical_device_name,
msdb.dbo.backupmediafamily.physical_device_name,msdb.dbo.backupset.name ASbackupset_name,
msdb.dbo.backupset.description
FROM msdb.dbo.backupmediafamily
INNER JOIN msdb.dbo.backupset ON msdb.dbo.backupmediafamily.media_set_id =
msdb.dbo.backupset.media_set_id
WHERE (CONVERT(datetime, msdb.dbo.backupset.backup_start_date,102)) >=cast(GETDATE()-150 AS date)
The result set is 230 rows, there are other database there that have been backed up daily. But the last result formydb
is from the same date as the backup that I restored.
– Petar Slavov
Jan 17 at 21:32
If you don't have any log or differential backups after the full backup then as Tibor said you need to restore the full backup with RECOVERY option. Are there any Log or Diff backups?
– user1716729
Jan 17 at 21:39
add a comment |
You can use the script below to get the backup report.It will help you to locate all the backup. Can you share the result of the query
SELECT msdb.dbo.backupset.database_name,msdb.dbo.backupset.backup_start_date,msdb.dbo.backupset.backup_finish_date,
msdb.dbo.backupset.expiration_date,
CASE msdb..backupset.type
WHEN 'D' THEN 'Database'
WHEN 'L' THEN 'Log'
WHEN 'I' THEN 'Differential'
END AS
backup_type,msdb.dbo.backupset.backup_size,msdb.dbo.backupmediafamily.logical_device_name,
msdb.dbo.backupmediafamily.physical_device_name,msdb.dbo.backupset.name ASbackupset_name,
msdb.dbo.backupset.description
FROM msdb.dbo.backupmediafamily
INNER JOIN msdb.dbo.backupset ON msdb.dbo.backupmediafamily.media_set_id =
msdb.dbo.backupset.media_set_id
WHERE (CONVERT(datetime, msdb.dbo.backupset.backup_start_date,102)) >=cast(GETDATE()-150 AS date)
You can use the script below to get the backup report.It will help you to locate all the backup. Can you share the result of the query
SELECT msdb.dbo.backupset.database_name,msdb.dbo.backupset.backup_start_date,msdb.dbo.backupset.backup_finish_date,
msdb.dbo.backupset.expiration_date,
CASE msdb..backupset.type
WHEN 'D' THEN 'Database'
WHEN 'L' THEN 'Log'
WHEN 'I' THEN 'Differential'
END AS
backup_type,msdb.dbo.backupset.backup_size,msdb.dbo.backupmediafamily.logical_device_name,
msdb.dbo.backupmediafamily.physical_device_name,msdb.dbo.backupset.name ASbackupset_name,
msdb.dbo.backupset.description
FROM msdb.dbo.backupmediafamily
INNER JOIN msdb.dbo.backupset ON msdb.dbo.backupmediafamily.media_set_id =
msdb.dbo.backupset.media_set_id
WHERE (CONVERT(datetime, msdb.dbo.backupset.backup_start_date,102)) >=cast(GETDATE()-150 AS date)
answered Jan 17 at 21:00
user1716729user1716729
18219
18219
The result set is 230 rows, there are other database there that have been backed up daily. But the last result formydb
is from the same date as the backup that I restored.
– Petar Slavov
Jan 17 at 21:32
If you don't have any log or differential backups after the full backup then as Tibor said you need to restore the full backup with RECOVERY option. Are there any Log or Diff backups?
– user1716729
Jan 17 at 21:39
add a comment |
The result set is 230 rows, there are other database there that have been backed up daily. But the last result formydb
is from the same date as the backup that I restored.
– Petar Slavov
Jan 17 at 21:32
If you don't have any log or differential backups after the full backup then as Tibor said you need to restore the full backup with RECOVERY option. Are there any Log or Diff backups?
– user1716729
Jan 17 at 21:39
The result set is 230 rows, there are other database there that have been backed up daily. But the last result for
mydb
is from the same date as the backup that I restored.– Petar Slavov
Jan 17 at 21:32
The result set is 230 rows, there are other database there that have been backed up daily. But the last result for
mydb
is from the same date as the backup that I restored.– Petar Slavov
Jan 17 at 21:32
If you don't have any log or differential backups after the full backup then as Tibor said you need to restore the full backup with RECOVERY option. Are there any Log or Diff backups?
– user1716729
Jan 17 at 21:39
If you don't have any log or differential backups after the full backup then as Tibor said you need to restore the full backup with RECOVERY option. Are there any Log or Diff backups?
– user1716729
Jan 17 at 21:39
add a comment |
I understand that you are not a DBA but like most of us we end up working on projects outside our domain. With that being said; caution should be your number one friend when working in unfamiliar terrorities. Backing up should be your next best friend in such situations. Anyways the harm is already done here and to be honest with you; it will be impossible to get back all the deleted objects if you do not have the correct backup set/chain.
You mentioned you are using a third party database repair tool. I know of one if thats not what you already using called Stellar Database Recovery Toolkit (https://www.stellarinfo.com/sql-recovery.php?gclid=EAIaIQobChMIzci5z4_W4AIVUNbACh1N8ARVEAAYAiAAEgIwCvD_BwE). This can repair corrupted databases and even recovery deleted database objects. The best part is the free trial version has all the features except saving the repaired file. So this is the trick, use the trial and see if the results of recovery is what you looking for. If it is, then viola purchase a full edition with guarantee that you will have your database recovered.
Best of luck and let me know how it goes!
add a comment |
I understand that you are not a DBA but like most of us we end up working on projects outside our domain. With that being said; caution should be your number one friend when working in unfamiliar terrorities. Backing up should be your next best friend in such situations. Anyways the harm is already done here and to be honest with you; it will be impossible to get back all the deleted objects if you do not have the correct backup set/chain.
You mentioned you are using a third party database repair tool. I know of one if thats not what you already using called Stellar Database Recovery Toolkit (https://www.stellarinfo.com/sql-recovery.php?gclid=EAIaIQobChMIzci5z4_W4AIVUNbACh1N8ARVEAAYAiAAEgIwCvD_BwE). This can repair corrupted databases and even recovery deleted database objects. The best part is the free trial version has all the features except saving the repaired file. So this is the trick, use the trial and see if the results of recovery is what you looking for. If it is, then viola purchase a full edition with guarantee that you will have your database recovered.
Best of luck and let me know how it goes!
add a comment |
I understand that you are not a DBA but like most of us we end up working on projects outside our domain. With that being said; caution should be your number one friend when working in unfamiliar terrorities. Backing up should be your next best friend in such situations. Anyways the harm is already done here and to be honest with you; it will be impossible to get back all the deleted objects if you do not have the correct backup set/chain.
You mentioned you are using a third party database repair tool. I know of one if thats not what you already using called Stellar Database Recovery Toolkit (https://www.stellarinfo.com/sql-recovery.php?gclid=EAIaIQobChMIzci5z4_W4AIVUNbACh1N8ARVEAAYAiAAEgIwCvD_BwE). This can repair corrupted databases and even recovery deleted database objects. The best part is the free trial version has all the features except saving the repaired file. So this is the trick, use the trial and see if the results of recovery is what you looking for. If it is, then viola purchase a full edition with guarantee that you will have your database recovered.
Best of luck and let me know how it goes!
I understand that you are not a DBA but like most of us we end up working on projects outside our domain. With that being said; caution should be your number one friend when working in unfamiliar terrorities. Backing up should be your next best friend in such situations. Anyways the harm is already done here and to be honest with you; it will be impossible to get back all the deleted objects if you do not have the correct backup set/chain.
You mentioned you are using a third party database repair tool. I know of one if thats not what you already using called Stellar Database Recovery Toolkit (https://www.stellarinfo.com/sql-recovery.php?gclid=EAIaIQobChMIzci5z4_W4AIVUNbACh1N8ARVEAAYAiAAEgIwCvD_BwE). This can repair corrupted databases and even recovery deleted database objects. The best part is the free trial version has all the features except saving the repaired file. So this is the trick, use the trial and see if the results of recovery is what you looking for. If it is, then viola purchase a full edition with guarantee that you will have your database recovered.
Best of luck and let me know how it goes!
answered 3 mins ago
samosqlsamosql
422212
422212
add a comment |
add a comment |
Thanks for contributing an answer to Database Administrators Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f227413%2frecovering-a-sql-server-database%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Unfortunately, in current circumstances, imho, it will be not possible to restore a database to a state more recent than that four month old backup. There is only one hope that that backup is not initialized every day and it contains more than one backup set
– Alexandr Volok
Jan 17 at 20:05
1
Can you execute: “restore headeronly from disk=‘path-to-backup’”. How many rows it returns?
– Alexandr Volok
Jan 17 at 20:08