|
|||||||||||||||||
|
Wouldn't it be nice to be able to recover individual tables from a backup file? So say you have a backup of the AdventureWorks database, and you only want to restore the Vendor table. Unfortunately, this isn't supported natively by SQL Server. You will need to rely on various third party tools to perform such tasks. The applications that usually offer this feature are the third-party backup applications for SQL Server. They allow you to extract or script out individual tables from the backup files that are created. However, there is one caveat. There is the possibility that the data you selectively restore, may be different from the data you would have obtained if you had performed a full database restore. The reason is because when you perform a full database backup, the resulting backup file contains a backup of both the data files and the transaction log files. There may be transactions that have been committed, that have not been written to the data file. In these cases, they are stored only in the transaction log, or stored partially in the data file. When the third-party application restores the selected tables, they only retrieve the data from the data file stored in the backup. The newer data in the transaction log is ignored.
How about transactions that have not been written to the data file before the backup started? This is not an issue, as SQL Server automatically performs a checkpoint when the backup is started. The dirty data pages would have been flushed out to disk during the checkpoint. So can we say that when we restore individual tables from a backup file, we are recovering the data as at the beginning of the backup? It depends. If there were no transactions running during the backup, yes. Or if there were transactions running but no checkpoints occurred, yes. If however there were transactions performed during the backup, the data we recover may include data at the beginning of the backup, and data that were committed during the backup IF checkpoints occurred during the backup AND the data was written to pages that were not yet backed up yet at the time the checkpoint occurred.
That's something to keep in mind when relying on table level recovery. A full backup contains all data and changes made to the database up to the time the backup ended. The data files alone do not reflect the state of the database at any particular point in time. Thus, a table level restore may contain outdated data. It may also result in inconsistent data if checkpoints occurred during a backup, where changes to one table are written to the backup file but changes to other tables are not as the extents that were stored in have already been written to the backup file. The applications that I tested that produced the above results were as follows:
Document history
|
||||||||||||||||||||