MSSQL paragraph Restore script

Source: Internet
Author: User
Tags filegroup mssql

--piecemeal Restore: Database corruption is relatively large, we have to restore the entire database across multiple data files or even across filegroups.
--If the database is particularly large, the database recovery time will be very long. However, we can use the piecemeal restore provided by SQL Server to gradually recover the database. --back up the tail log first:BACKUP LOG [AdventureWorks] to DISK =N'D:\BACKUP_TEST\LOG_BACK_TAIL.trn' withNo_truncate, Norecovery,compression,stats=Ten--Partial Restore PRIMARY filegroup primary:RESTORE DATABASE [AdventureWorks]FILEGROUP=N'PRIMARY' from DISK=N'D:\BACKUP_TEST\AD_FULL.bak' withPartial,norecovery,stats=Ten--To restore a sub-filegroup MST:RESTORE DATABASE [AdventureWorks]FILEGROUP=N'MST' from DISK=N'D:\BACKUP_TEST\AD_FULL.bak' withNorecovery,stats=Ten--Restore the log in turn:RESTORE LOG [AdventureWorks] from DISK=N'D:\BACKUP_TEST\LOG_BACK_1.TRN' withNorecovery,stats=TenRESTORE LOG [AdventureWorks] from DISK=N'D:\BACKUP_TEST\LOG_BACK_2.TRN' withNorecovery,stats=Ten--restore tail logs and restoreRESTORE LOG [AdventureWorks] from DISK=N'D:\BACKUP_TEST\LOG_BACK_TAIL. TRN' withRecovery,stats=Ten--files located in the primary and MST filegroups in the AdventureWorks database are now accessible. --However, tables that are located in other filegroups, such as the TRN filegroup, are not yet accessible. --msg 8653, Level 16, State 1, line 2nd--The query processor cannot generate a schedule for a table or view "* * *" because the table resides in a filegroup that is not online.
--Next, restore the sub-filegroup trn:RESTORE DATABASE [AdventureWorks]FILEGROUP=N'TRN' from DISK=N'D:\BACKUP_TEST\AD_FULL.bak' withNorecovery,stats=10
--If the database is not an Enterprise edition, the above restore will prompt " the Database" AdventureWorks "has not been backed up for the tail of the log. "
--You need to back up the tail of the log again, meaning that the entire database is in the restoring state when you restore the TRN file group. So for non-enterprise editions, only offline piecemeal restore, the personal feel that the meaning is not very big ...--Restore the log in turn:RESTORE LOG [AdventureWorks] from DISK=N'D:\BACKUP_TEST\LOG_BACK_1.TRN' withNorecovery,stats=TenRESTORE LOG [AdventureWorks] from DISK=N'D:\BACKUP_TEST\LOG_BACK_2.TRN' withNorecovery,stats=Ten--restore tail logs and restoreRESTORE LOG [AdventureWorks] from DISK=N'D:\BACKUP_TEST\LOG_BACK_TAIL. TRN' withRecovery,stats=Ten--the table in the sub-filegroup trn is now accessible. --piecemeal restore all complete

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.