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

  • 相关阅读:
    Sencha Touch id 和 itemId
    解决VS报表.rdl 显示乱码“小方块”问题
    C# 调试程序弹出 没有可用于当前位置的源代码 对话框
    解决DropDownList 有一个无效 SelectedValue,因为它不在项目列表中。这是怎么回事?
    CS0016: 未能写入输出文件“c:windowsMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Filesdata34aae0607daa87dApp_Web_addadvice.aspx.cdcab7d2.ekhlcbjd.dll”--“目录名无效。 ”
    利用微软类库 Visual Studio International Pack 汉字转拼音
    【C#】线程之Parallel
    【C#】线程之Task
    【C#】线程协作式取消
    【C#】属性(Attribute)
  • 原文地址:https://www.cnblogs.com/justdba/p/5505046.html
Copyright © 2011-2022 走看看