zoukankan      html  css  js  c++  java
  • 基于时间点恢复数据库stopat

    create database newtestdb

    use newtestdb
    go


    drop table t1
    go

    create table t1 (
    id int not null identity(1,1) primary key
    ,vdate datetime default (getdate())
    ,name varchar(32)
    )


    backup database newtestdb to disk='c: ewtestdb_ful.bak'
    insert into t1 (name) values ('aa')

    insert into t1 (name) values ('bb')
    backup log newtestdb to disk='c: ewtestdb_1.trn' --2016-05-18 13:42:30.767
    select getdate()


    insert into t1 (name) values ('cc')
    backup log newtestdb to disk='c: ewtestdb_2.trn' --2016-05-18 13:43:59.707
    select getdate()


    insert into t1 (name) values ('dd')
    backup log newtestdb to disk='c: ewtestdb_3.trn' --2016-05-18 13:45:05.310
    select getdate()


    insert into t1 (name) values ('ee')
    backup log newtestdb to disk='c: ewtestdb_4.trn' --2016-05-18 13:46:29.783
    select getdate()


    insert into t1 (name) values ('ff')
    backup log newtestdb to disk='c: ewtestdb_5.trn' --2016-05-18 13:47:21.833
    select getdate()


    --恢复到dd
    use master
    go
    restore database newtestdb from disk='c: ewtestdb_ful.bak' with replace,norecovery;
    /*
    Processed 344 pages for database 'newtestdb', file 'newtestdb' on file 1.
    Processed 6 pages for database 'newtestdb', file 'newtestdb_log' on file 1.
    RESTORE DATABASE successfully processed 350 pages in 0.025 seconds (109.179 MB/sec).
    */
    restore log newtestdb from disk='c: ewtestdb_1.trn' with replace,norecovery,stopat='2016-05-18 13:45:09.310';
    /*
    Processed 0 pages for database 'newtestdb', file 'newtestdb' on file 1.
    Processed 7 pages for database 'newtestdb', file 'newtestdb_log' on file 1.
    This backup set contains records that were logged before the designated point in time. The database is being left in the restoring state so that more roll forward can be performed.
    RESTORE LOG successfully processed 7 pages in 0.008 seconds (6.103 MB/sec).
    */
    restore log newtestdb from disk='c: ewtestdb_2.trn' with replace,norecovery,stopat='2016-05-18 13:45:09.310';
    /*
    Processed 0 pages for database 'newtestdb', file 'newtestdb' on file 1.
    Processed 1 pages for database 'newtestdb', file 'newtestdb_log' on file 1.
    This backup set contains records that were logged before the designated point in time. The database is being left in the restoring state so that more roll forward can be performed.
    RESTORE LOG successfully processed 1 pages in 0.006 seconds (0.325 MB/sec).
    */
    restore log newtestdb from disk='c: ewtestdb_3.trn' with replace,norecovery,stopat='2016-05-18 13:45:09.310';
    /*
    Processed 0 pages for database 'newtestdb', file 'newtestdb' on file 1.
    Processed 1 pages for database 'newtestdb', file 'newtestdb_log' on file 1.
    This backup set contains records that were logged before the designated point in time. The database is being left in the restoring state so that more roll forward can be performed.
    RESTORE LOG successfully processed 1 pages in 0.006 seconds (0.325 MB/sec).
    */
    restore log newtestdb from disk='c: ewtestdb_4.trn' with replace,norecovery,stopat='2016-05-18 13:45:09.310';
    /*
    Processed 0 pages for database 'newtestdb', file 'newtestdb' on file 1.
    Processed 1 pages for database 'newtestdb', file 'newtestdb_log' on file 1.
    RESTORE LOG successfully processed 1 pages in 0.004 seconds (0.488 MB/sec).
    */
    restore log newtestdb from disk='c: ewtestdb_5.trn' with replace,norecovery,stopat='2016-05-18 13:45:09.310';
    /*
    Msg 4305, Level 16, State 1, Line 57
    The log in this backup set begins at LSN 34000000022700001, which is too recent to apply to the database. An earlier log backup that includes LSN 34000000022500002 can be restored.
    Msg 3013, Level 16, State 1, Line 57
    RESTORE LOG is terminating abnormally.
    */

    restore database newtestdb with replace,recovery;
    /*
    RESTORE DATABASE successfully processed 0 pages in 0.086 seconds (0.000 MB/sec).
    */

    --成功恢复至dd

    select * from newtestdb.dbo.t1


    id vdate name
    1 2016-05-18 13:41:44.500 aa
    2 2016-05-18 13:42:26.767 bb
    3 2016-05-18 13:43:57.707 cc
    4 2016-05-18 13:45:05.290 dd

  • 相关阅读:
    高德地图js开发,给城市某个区添加颜色
    threejs 实现易拉罐换肤功能
    React 跨页面保留前一页状态的一种实现方法
    nginx 解决客户端跟服务跨域问题
    React图片预览组件,支持缩放、旋转、上一张下一张功能
    h5 高德地图开发 谷歌浏览器定位失败解决方案
    echarts点击省份显示对应的省份
    sec:authorize 标签 通过不通过权限例子
    择左边多选框的值移动到右边多选框
    更改css element.style
  • 原文地址:https://www.cnblogs.com/justdba/p/5505046.html
Copyright © 2011-2022 走看看