Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2004
    Posts
    3

    Unanswered: restore to new db restores less data than what is in the source backup file

    I am trying to create sql code that restores a backup of a master database to a new database on the same server. It “seems” to run correctly as no errors are produced. However, the most recent updates to the master database are not present in the new databases. All databases are using the Full recovery model. What is really strange is that if I do (what I think is) the same function in Enterprise Administrator, the restore works fine! For both methods I used the same backup file!



    Any and all help is sincerely appreciated.


    The master databases from which the backups are made start with “MODTRNMaster”

    The databases which are created from the restores start with “M1_” and “M2_”. (We call them training room databases.)



    My script for backing up the master databases:



    -- Backup the master training database

    backup database MODTRNMaster
    to disk = 'f:\bkup\MODTRNMaster.bak'

    backup database MODTRNMaster_IMG
    to disk = 'f:\bkup\MODTRNMaster_IMG.bak'

    backup database MODTRNMaster_MNC
    to disk = 'f:\bkup\MODTRNMaster_MNC.bak'

    backup database MODTRNMaster_VM
    to disk = 'f:\bkup\MODTRNMaster_VM.bak'

    go


    This is the restore script for restoring the first training room databases. I’m hoping that there is just something simple that I’m overlooking in these restore statements! J



    -- Restore the backup of the master training database into the

    -- training room #1 database.

    use master
    go

    drop database M1_MSLH
    go


    restore database M1_MSLH
    from disk = 'f:\bkup\MODTRNMaster.bak'
    with move 'DEV5_Data' to 'f:\mssql\data\M1_MLSH.mdf',
    move 'MM' to 'f:\mssql\data\M1_MLSH_1.mdf',
    move 'AMB' to 'f:\mssql\data\M1_MLSH_2.mdf',
    move 'DM' to 'f:\mssql\data\M1_MLSH_3.mdf',
    move 'IMM' to 'f:\mssql\data\M1_MLSH_4.mdf',
    move 'ED' to 'f:\mssql\data\M1_MLSH_5.mdf',
    move 'DEV5_Log' to 'f:\mssql\log\M1_MLSH_log.ldf',
    recovery

    go



    Thanks in advance




  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    that surely sounds like some magic. I do not know off the the top of my head what the problem could be but you should only have one mdf file and the rest of your data files should be ndfs.
    Last edited by Thrasymachus; 01-26-06 at 09:24.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Dec 2002
    Posts
    1,245
    I am trying to create sql code that restores a backup of a master database to a new database on the same server. It “seems” to run correctly as no errors are produced. However, the most recent updates to the master database are not present in the new databases. All databases are using the Full recovery model. What is really strange is that if I do (what I think is) the same function in Enterprise Administrator, the restore works fine! For both methods I used the same backup file!
    Are you sure that the master database is in full recovery mode? I did not think that was possible and/or mattered.

    Also, even if it is in full recovery, your restore script indicated that you had restored only the last full backup (.BAK) file and had not restored any transaction logs (.TRN). Without restoring the transaction logs, you will only restore the database to the point in time when the last full backup completed; any transacations performed after that will not get restored.

    Finally, I have to ask: why are you restoring the master database? I'm not sure that doing so gets you anything (except maybe practice).

    Regards,

    hmscott
    Have you hugged your backup today?

  4. #4
    Join Date
    Oct 2004
    Posts
    3
    sorry. I should have been a little clearer. It is not actually THE master database that I'm backing up. We are having some training sessions for users of a new system. The trainer makes his updates in a database named MODTRNMaster (the master database for our purposes). At night I am restoring into 2 individual training databases M1_MLSH and M2_MLSH that the users are accessing.

    No transaction log backups are being done. These databases are only being accessed during the day. At night there is no activity in those databases. At night I backup MODTRNMaster and then immediately (attempt to) restore the backup file as M1_MLSH and then again as M2_MLSH.

  5. #5
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,799
    Provided Answers: 11
    You need to add with init to your backup commands, or with file = # to the restore commands. By default, SQL Server will append your backup to the exisiting file (you may have noticed them getting bigger), and restore from the first backup found. Do this and get back to us with the results:
    Code:
    restore headeronly from disk = 'f:\bkup\MODTRNMaster.bak'

  6. #6
    Join Date
    Oct 2004
    Posts
    3
    Thanks So much for your suggestion! Adding the "init" parameter to the backup database statement was exactly what was needed!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •