Thursday, March 08, 2007 10:01 AMHi,
I'm busy trying to restore a database and it doesn't work because I don't have enough space on my HardDisk.
The error message is very clear, it tells me that I need 4334944256 bytes free space and I have only 3382329344 bytes which are free.
Of course if I want that it works I just have to make some more free space .... but that's not my question.
I would like to know what "exactly" happen when you restore a database because my .bak file has only 84412 bytes and the original .mdf file 3072 kbytes.
So why the process needs to have such a big amount of free space ?
Thanks for your response.
Friday, March 09, 2007 9:00 PMModerator
The backup only contains those extents, or groups of pages which are allocated and in use. For all pages which have not been touched, we don't copy the into the backup. So, this explains why the backup file can be so much smaller than the original database.
The restored database must be the same size as the original database because those clumps of allocated pages are not all grouped in the beginning of the file. They could be anywhere in the file, and if we move them by shrinking the file during restore, then all of the internal references would be broken.
Finally, during restore you are not only restoring the .mdf file, but the log file as well, which may account for the extra space above the size of the source mdf file.