MSSQL – Two common issues while restoring a backup and it’s solutions

There are two most common issues while restoring the database (usually ending in .bak format).

First error
System.Data.SqlClient.SqlError: The backup set holds a backup of a database other than the existing ‘user_database‘ database. (Microsoft.SqlServer.Express.Smo)

Solution for First error

  • Connect to the database server
  • Logging in to the web server

  • Go to the restore option and select Restore Database

  • On the Restore page that loads up, make sure that the Destination for restore has the database you want to restore and in the Source for Restore, choose From device: And browse by clicking [..] and Add the file location there, the location where your database backup resides. You may need to browse the backup. If you get permission denied, copy the bak in the MSSQL folder.

    Attaching the database backup file

    Attaching the database backup file

  • Restore it. Make sure that the Restore Checkbox is selected. And Click OK. And get ready for the error :)

  • Here comes the first errorSystem.Data.SqlClient.SqlError: The backup set holds a backup of a database other than the existing ‘user_database’ database. (Microsoft.SqlServer.Express.Smo)
    And the solution is to go to Options -> Overwrite Existing Database . But if you aren’t so lucky, you will be welcomed by another error as seen below. where it’s solution is to edit the path from D:\ to C:\ or whichever Drive, where your MSSQL is installed.

    System.Data.SqlClient.SqlError: Directory lookup for the file “D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\user_database.mdf” failed with the operating system error 3(The system cannot find the path specified.). (Microsoft.SqlServer.Express.Smo)

  • Both THE Solutions are in a single screen shot. The final screenshot :)

  • Just edit D:\ProgramFiles\Microsoft… to C:\ProgramFiles\Microsoft or whichever directory where you installed the MSSQL server. Don’t keep database server on your system drive C: though.
  • Post to Twitter Tweet This Post

    Continue Reading

    How to mount a LVM from a crashed and backup drive to the new HD to restore data

    Situation & Requirement

    Server crashed and had to be reinstalled. OS along with cPanel was re-installed on a fresh hard disk. Needed to restore the cPanel backup from old LVM hard disk to the new hard disk. That process wasn’t simple as I was getting unrecognised file system errors.

    Solution

    Made sure that the lvm tools are installed and available in the server. After that issued the following command

    lvm vgchange –ignorelockingfailure -P -a y

    The -P (Partial) will make logical volumes which are missing one of their disks available too.

    vgchange — Change attributes of a volume group

    –ignorelockingfailure — This lets you proceed with read-only metadata operations such as lvchange  -ay and vgchange -ay even if the locking module fails. One use for this is in a system init script if the  lock  directory is mounted read-only when the script runs

    -a — active or available

    lvm lvs

    The above command gives you output showing the name of the Volume Group and the name of the Logical Volume. The device entry will be created like /dev/VolGroup00/LogVol00/ and /dev/VolGroup00/LogVol01 etc. Finally run a fsck command to make it free of file system errors.

    fsck /dev/VolGroup00/LogVol00

    You are all set to go from here. As long as the lvm partition isn’t corrupt, following commands will get the oldhdd mounted to /oldhdd

    mkdir /oldhdd
    mount /dev/VolGroup00/LogVol00 /oldhdd

    This isn’t my tutorial. “Shamelessly” leeched from http://www.techbytes.ca/techbyte118.html

    Post to Twitter Tweet This Post

    Continue Reading

    Your email:

     

    Post to Twitter Tweet This Post

    About this blog

    This blog, acts as a knowledge repository for the world and is unofficial! Anything we find interesting in the cyber world will go here. Most cases, this blog will reflect the happiness of our staff in reaching successful solution to an issue (s)he worked on. A reference for other fellow SAGEs who come across similar issues later