November 15, 2010 at 11:43 am
I know this does not work (as just tried it 🙂 ) but just curious why not? I truncated huge table, let say 350 GB in 400 DB. Backup size certainly came down to 50 GB, but it was restored to 400 GB DB again (with unallocated space 350 GB). Only shrinking file resulted in 50 GB DB. It seems backup file "remembers" original DB space?! Any comments/clarification really appreciated.
November 15, 2010 at 11:56 am
November 15, 2010 at 12:17 pm
Sorry, probably was not clear.
After shrink and backup/restore I certainly got 50 GB DB
(as 350 GB unallocated space gone during shrink).
I am wondering why before shrink backup file with size 50 GB was restored to original 400 GB DB?
November 15, 2010 at 12:27 pm
November 15, 2010 at 12:43 pm
Sorry I did not get what "session" means?
First, table 350 GB size was truncated, then using RedGate Sql Backup I made backup (around 50 GB size), then using RedGate I restored DB to ... initial (before shrink) 400 GB. Not sure what is "session" here? Thanks
November 15, 2010 at 12:48 pm
November 15, 2010 at 12:51 pm
November 15, 2010 at 1:03 pm
I am afraid there is no option ( I certainly can be wrong) in restore statement (I just double checked BOL) that allows you retrieving free space during DB restoring. But instead there is probably some (hidden to me :-)) idea why it can not be done during DB restoring and this actually my question is about. Thanks
November 15, 2010 at 1:08 pm
Restore simply creates the database file the way they were when the backups was made.
If you need to shrink them after the restore, you will have to set that up yourself.
November 15, 2010 at 2:33 pm
The backup backs up the current state of the database. If you did a RESTORE HEADERONLY from BackupDevice... you will see it is expecting 400GB of space. There is no way (currently) the restore can decide that you want to shrink the unused space, and discard it when it does the restore. Also the actual data pages could be scattered all over the 400GB of files, so SQL would also need to do a reorg to sort this out. In simple terms what the backup does is:
1) Backup data pages only (indexes etc included), this is why the backup is so small.
2) Track where those are within the 400GB of files
3) Record the file names, paths, sizes so they can be recreated on restore.
When you do a restore SQL creates the same size files as were backed up and then populates them with the data pages.
If you want to remove the unused space you need to do a shrink of the files/database. Sorry, there are no short cuts.
Cheers
Leo
Leo
Nothing in life is ever so complicated that with a little work it can't be made more complicated.
November 15, 2010 at 2:58 pm
Thanks Leo,
It seems I can not avoid shrinking
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply