crimdon / SQLToolkit

An Extension for Azure DevOps Server
MIT License
17 stars 14 forks source link

Run backup, only if database exists #45

Closed codepb closed 6 years ago

codepb commented 6 years ago

Hi,

I'm using the SQL Backup tasks, and was wondering if there was a way to only run it if the database exists? Looking at the script, it appears the check could be added by running a SQL query to see if a database by the name exists first before running the backup command.

codepb commented 6 years ago

I've looked into this, and it should be as simple as adding "IF db_id('$databaseName') IS NOT NULL" to the start of the backup command. I don't know if you would prefer to include this by default or have it as a configurable parameter in VSTS. I can create a pull request to implement this if you'd like?

crimdon commented 6 years ago

I think I'd rather add a tick box and make the check optional.

You could also do it via you own script and run that using the Single Script task.

codepb commented 6 years ago

I'll see if I can figure out how that works and submit a pull request. Thanks.

crimdon commented 6 years ago

This should go out in the next release next week