12

I have done a lot of research about this.

I am attempting to recover a database with SQL Server 2014 and it keeps hanging at 100%.

A lot of people suggest that the solution is to just make sure that you restore with the RECOVERY option.

I have tried that and it still hangs at 100%. I have tried via the SSMS Restore dialog and I have tried running the following SQL Statement:

USE [master]
RESTORE DATABASE [MyDB]
FROM  DISK = N'C:\MyDB_backup_2015_05_05_010004_1506557.bak'
WITH  
    FILE = 1,  
    MOVE N'MyDB_Data' TO N'F:\MSSQL\DATA\MyDB.mdf',  
    MOVE N'MyDB_Log' TO N'F:\MSSQL\DATA\MyDB_1.ldf',  
    NOUNLOAD,  
    REPLACE,  
    RECOVERY,
    STATS = 2
GO

When I check the status of the command via:

SELECT r.status, r.command, r.wait_type, r.percent_complete
FROM sys.dm_exec_requests r
WHERE r.command like '%restore%' or r.command like '%backup%'

I get:

status: suspended
command: RESTORE DATABASE
wait_type: BACKUPTHREAD
percent_complete: 100

Which from my reading implies that the RESTORE is waiting for a BACKUP to complete, but there is no BACKUP command returned from my query to sys.dm_exec_requests

EDIT: After trying it again and running the above query to watch the progress of the RESTORE from the beginning, I can see that the 'percent_complete' value is increasing steadily, despite the fact that the 'status' remains as 'suspended' and the 'wait_type' remains as 'BACKUPTHREAD'.

So despite it being 'suspended' it is actually still performing the RESTORE.

So I'm at a loss...

Anyone got any ideas what's going on here or any tips on how to diagnose the issue?

Cheers!

6
  • Can check sp_who and sp_who2 to know which db has a pending backup?
    – Esselans
    Commented May 6, 2015 at 1:50
  • There are no rows from sp_who or sp_who2 which contain a cmd 'BACKUP'
    – JTech
    Commented May 6, 2015 at 2:34
  • 1
    How long have you waited? How big is your log file? How many VLFs does it contain? What was the status of the database at the time the backup was taken? Did you try with trace flags 3004 and 3014? (See this post.) Commented May 6, 2015 at 4:58
  • It is a nightly backup which I did not create - hence don't know what status the database was in when it was created. All I have is the .BAK file. How can i tell how big the log file is or how many VLFs it contains?
    – JTech
    Commented May 6, 2015 at 5:08
  • 1
    Sometimes it stops at 100% for a few minutes. Don't give up too fast.
    – JoelFan
    Commented May 22, 2018 at 1:09

2 Answers 2

8

As it turns out the issue was environmentally related and pretty straight forward:

First of all, I was attempting to back up from a non-shrunk back up version of the origin database.

The size of the log files was actually a known issue, hence we usually back up from a shrunk version of the database.

So if anyone is having a similar problem, trying shrinking the database first and then backing it up and restoring from that.

Secondly, I was attempting to backup the database to an external drive over USB3.

Also, interestingly, I watched the progress of the working restoration command and it too had a status of 'suspended' with 'wait_type' "BACKUPTHREAD" - even whilst it was still progressing (as evident by the percentage of completion increasing in the percent_complete) column! So I'm still lost as to what thats about...

But at least I can restore my backups now :-)

1
  • This is probably it, but for me it just took 20 min (and getting a new copy of the db would have been a pain) so maybe just wait?
    – Mike Weiss
    Commented Sep 13, 2023 at 15:45
3

I had the same problem it was due to the size of the DB. Although the backup shows 9 MB, when I right click the DB in SQL server management and select properties, the size shown was 25 GB! What I did is that I changed the DB to "Simple Recovery", shrinked the log file,backup again, and I could restore now.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.