Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insufficient disk space when restoring a small backup

I'm trying to restore a database from 32MB backup. I have 6GB available on my disk. When I'm trying to restore the backup it shows the insufficient disk space error. How is it possible that a 32MB backup requires more than 6GB of disk space?

like image 300
andr111 Avatar asked Mar 11 '13 20:03

andr111


2 Answers

Probably because the backup is compressed, or because there is a very large log file that doesn't need to be part of the backup itself, or because the data file itself has been cleaned out - the backup is only comprised of pages that contain data. But when restored, it still has to expand the data file to its original size, even if most of it is empty.

Show us what the size column says when you run:

RESTORE FILELISTONLY FROM DISK = '[path]\whatever.bak';
like image 189
Aaron Bertrand Avatar answered Oct 14 '22 00:10

Aaron Bertrand


I had the same issue, I had a 800 MB database backup file which needed 320 GB free space to be restored in destination computer.

Turned out it was just because of database log file, to make sure log file is what caused the matter, right click on intended databse and click on properties, after that in General tab check Size of the database, if it's huge, go to the Files tab and navigate to the path of tfiles.

I ran Shrink command on database and on files through interface but it didn't help, following query saved me eventually:

ALTER DATABASE DataBase_Name SET RECOVERY SIMPLE;
GO
DBCC SHRINKFILE(DataBase_Name_log, 200);
GO
ALTER DATABASE DataBase_Name SET RECOVERY FULL;
GO

It means you have to run query on the database, then create a back file once again.

NB: As you see in the query above, Database recovery mode should be on Simple before SHRINKFILE be executed.

like image 40
Muhammad Musavi Avatar answered Oct 13 '22 23:10

Muhammad Musavi