Home  >  Article  >  Backend Development  >  Use database logs to restore data to point operations_PHP tutorial

Use database logs to restore data to point operations_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:03:401045browse

Many friends may have encountered this problem:
The update or delete statement forgot to include the where clause, or the where clause was not precise enough, which caused serious consequences after execution. Data recovery in this case can only be done by using Transaction log backup is performed, so if your SQL does not have a corresponding full database backup or cannot back up the log (the truncate log on checkpoint option is 1), then the data cannot be restored, or it can only be restored to the latest The data is backed up.
The following is a brief description of the data recovery method:
1. If there was a full database backup (or multiple differential backups or incremental backups) before the misoperation, the first thing to do is to perform a log backup ( If you set the trunc.log on chkpt. option to 1 in order to prevent the log file from becoming larger, you will be in trouble)
backup log dbName to disk='fileName'
2, restore a full database backup, please note Need to use with norecovery, if there are other differential or incremental backups, restore one by one
restore database dbName from disk='fileName' with norecovery
3, restore the last log backup, which is the log backup just made, specify Restoration time point to the moment before the misoperation
restore log dbName from disk='fileName'
with stopat='date_time'
All of the above operations can be completed in SQL SERVER Enterprise Manager and are not difficult. . . .
Of course, if the misoperation is some unlogged operation such as truncate table, select into, etc., then the above method cannot be used to recover the data...


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630950.htmlTechArticleMany friends may have encountered this problem: the update or delete statement forgot to include the where clause, or The where clause is not precise enough, causing serious consequences after execution. Data recovery in this case...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn