Restore SQL Server databases from logs to time points

xiaoxiao2021-03-06  90

Author: David Eulerdate: 2004/10 / 16Email: de_euler-david@yahoo.com.cn

if you have any problem, please contact me:)

DB2 can cause the database to reply to the specified point in time, the Recovery Model of the SQL Server database is Full or Bulk Copy, it is possible to recover the database from the log. In fact, one of the transact sql statements recorded in the log will recover these SQL statements when recovering the database. Prerequisites: Mybbs is a table in the database TEST,

Database Test's Recovery Model is Full, Auto Close, Auto Shrink two options are not selected.

Database Test's Data Files and Log Files are both default automatic growth.

A: 2004/10/13, 16: 00 For database backup, Backup Database Test to disk = 'd: /db/1600.bak' with init

B: 2004/10/14, 13: 00 The database is performed on the database;

C: 2004/10/15, 18: 00 When using delete mybbs where id> 300, the statement is mistaken into delete mybbs, thus deleting all the data in Table MyBBS.

Now in the C point, the C point is wrong to the database, we hope that the database can restore the state before C, such as the status of 17:59 on October 15.

To restore the database B, use the A point backbone database 1600.bak; useful log backup is the latest 备 1820.logs; thus doing the following:

- NEW log:

Backup log test to disk = 'd: /1820.logs' with init

- Restore Database 1600.bak, use the use of Norecovery parameters:

RESTORE DATABASE TEST from disk disk = 'd: /db/1640.bak' with Norecovery

- Use log recovery databases from 17:59 on October 15:

Restore log test from disk = 'd: /1820.logs' with recovery, stopat = '10 / 15/2004 17:59

The corresponding process of the above three Transact SQL statements: 1. Restore the database to a point; 2. Execute the log record between A-B, restore the database to the B point. This restores the database to the specified point in time. If the recovery is unsuccessful, the possible reasons are: 1. Not used the correct backup database; 2. The database option is selected for Auto Shrink.

转载请注明原文地址:https://www.9cbs.com/read-105536.html

New Post(0)