相信不少人都有删库或被删库的经历。当事情发生后,是跑路,还是自首?相信每个人都没有想过这两个选项,大家首先想到的是如何恢复数据。

今天我们将进行一个实验,试图在删库后悄悄的恢复数据,然后假装什么都没发生,继续混点。
实验目的
通过Microsoft Sql Server 的数据库日志,恢复被删的表及数据。
此实验过程适用于以下场景:
- 数据被删
- 表被删
- 错误的UPDATE
- 错误的表结构更改
实验条件
- Microsoft Sql Server 2008 R2
- 数据库有很久以前的备份
- 数据库最新的数据没有备份
- 数据库还在,表没了
- 数据库恢复模式是“完整”级别
实验过程
1、首先,我们创建一个数据库,创建一个表,弄点数据进去,并做一个备份。
特别强调,我们数据库的恢复模式应为“完整”,不要为了节省磁盘空间,而去收缩数据库日志,或把日志设为简单。



2、下面,我们假装业务在继续,又有新的数据产生了,这时候我们要记录一个时间点,即表或数据被删除前一刻的时间。

记录时间点,稍微缓几分钟,然后删除数据,记住,这波数据是没有备份的。

3、好了,假装有客户投诉发现数据异常,这时候我们发现数据不见了,库里面空如也,不要慌,先把日志备份一波。

4、把以前的旧备份,还原为一个新的库,切记,不要弄到旧库上去了,不然哭不死你。

5、敲黑板,重点,还原的时候,在选项中选择图中红框标记的那项,这样我们才能在下一步中进行事务日志还原。

6、这时候,新的数据库显示为(XXX正在还原),右键——任务——还原——事务日志

7、选择我们刚才用SQL备份的那个日志,设置时间点为我们刚才记下的时间。还原


PS:由于实验途中被一波电话打断几小时,回来又重搞了一遍,有些图和内容有点不匹配,以后有空再改,见谅

网友评论