Shrink Log file when restoring a backup?

  • I am trying to restore a *.bak file that has a 20 gig log file and only about a 2 gig database file. Is there away to restore the bak file without the log file and/or shrink the log file within the bak file?

    Any ideas would be appreciated.

    DanielP

  • I don't know of a way to achieve what you're trying to do - that is shrink the 20gb log component of the backup before restoring, or tell restore to shrink it on the fly.

    However, if your disk space is at a premium, the following may be worth a try. I've just tested it with a much smaller database and it worked ok....

    Create a new "compressed" NTFS Folder.

    Execute the restore, using MOVE option to direct the DATA component to your normal data directory, but the LOG component to this compressed folder. It may fit.

    In Windows Explorer look at the properties of the restored log, it's "size on disk" should be considerably smaller than its reported size.

    Detach the database.

    Delete the LOG file.

    Attach the database, specifying only the DATA file. A new LOG should be created in your default log directory.

    Delete the compressed folder (and don't you dare use compressed folders for database files again! )


    Cheers,
    - Mark

  • NO you can't restore just the data from a backup file. It's good practice to shrink the log file before you take the backup

    Shas3

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply