Powershell for SQL repair

  • Please advise..does it make sense and possible for powershell to run SQL server repair instead of manual process like go to ISO or setup.exe and trigger installation and do the repair from maintenance and click next.'

    Why I want to do that - because repair is sometimes done once a week in our environment for resolve some issues. Which is different discussion. Please share your thoughts on powershell.

  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

  •  

    Thanks for the bump. I appreciate it.

    Maybe I posted the question with incomplete information I do not know. I always had the idea of using powershell for installs like repairs etc and wanted to learn more about it.

     

  • I believe powershell can handle that, but most setup applications have silent options so powershell may be overkill for it.

    That being said, I would be more concerned about why your SQL instance gets to a point where you need to do weekly repairs.  Where I work, we have had SQL Server running with the only interruptions being for patching.  I have not had to do a repair install on any SQL instance .

    But to do a silent repair:

    Setup.exe /q /ACTION=Repair /INSTANCENAME=instancename

    that is taken from the Microsoft documentation (https://docs.microsoft.com/en-us/sql/database-engine/install-windows/repair-a-failed-sql-server-installation?view=sql-server-2017).  That command can be run from powershell, but a simple bat file or manually typing it in is probably good enough.  I feel like powershell is overkill for what you are trying to do.

    The above is all just my opinion on what you should do. 
    As with all advice you find on a random internet forum - you shouldn't blindly follow it.  Always test on a test server to see if there is negative side effects before making changes to live!
    I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.

  • Finally I get some help. Thank you!

    I would really would like to look into how to use 'Setup.exe /q /ACTION=Repair /INSTANCENAME=instancename' properly.

    I am sorry..we do repairs only when there is Linux or windows servers are patched which is like once or twice a month.

    Why we do it - Because of a bug with one of the SSIS instance. The Backup job which is a SSIS package seems ot fail after patching. So repair for some reason fixes it.

    Now, I am new to the handed environment and investigating to learn efficient ways. One of them is moving to file based.

     

     

  • When I am installing SQL Server on a server, I usually copy the contents of the DVD to the machine.  This allows me to install new instances quickly and easily without needing to remount the ISO (as I have no access to the tools that would let me do that).

    But once you have the image mounted to the OS, you would just start up a command prompt, navigate to the location where the installer is located and run that command replacing "instancename" with the name of the instance you wish to repair.

    On linux, it'll be a slightly different command as "exe" files don't run on linux.  We have no linux boxes where I work, so I don't know a lot about how that works on the linux side.

    I am still not sure what causes the SSIS package to fail though.  We have a lot of SSIS packages that run daily on our system at work and have not had any problems with them failing due to windows updates.

    As a different approach rather than doing the repair install so frequently, is having your backup job in SSIS a requirement of your employer?  If not, you could change it to straight T-SQL.

    A different approach to your backup strategy though could be to move that to straight T-SQL instead of an SSIS package.  I am in the middle of doing almost that right now.  Moving from maintenance plans to T-SQL.  My scripts are ready for my environment (they are very tailored to my environment), I just want to get more testing done before putting them live.

    The above is all just my opinion on what you should do. 
    As with all advice you find on a random internet forum - you shouldn't blindly follow it.  Always test on a test server to see if there is negative side effects before making changes to live!
    I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.

Viewing 6 posts - 1 through 5 (of 5 total)

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