We have a job which backs up all ONLINE databases nightly, but for some reason it didn't back up msdb
. So the issue is at that time msdb was in some status was other then 0. So my question is : is it possible to back up a database if its status is not online (either RESTORING, RECOVERING, RECOVERY_PENDING, SUSPECT, EMERGENCY)?
migrated from stackoverflow.com May 2 at 15:11
This question came from our site for professional and enthusiast programmers.
It appears that no you can not backup a database in an offline state based on this comment from BOL. Offline and Emergency appear to be the exceptions.
However that being said the chances of the database state being the reason for your backup problem are slim. As said in the comments by @StrayCatDBA MSDB is required to do backups (among other things). You can look at the error for a backup by right clicking on your maintenance plan (assuming you are using one) and selecting view history. Once you are in the Log File Viewer you can see what errors you have. Click on the + to drill down to details and then select each of the lines with the red X in turn to see what the current error is. In this particular case we had a maintenance plan that was trying to back up databases that no longer existed. Once they were removed from the plan we stopped getting the errors. |
|||||||||
|
The possible values in the State and State_Desc columns of sys.databases are:
From your question, I am assuming that the backup job is called using a script, which queries and gets the value of state column, backs up if 0, or skips to next DB if state <> 0. Sadly with this approach, there would be no exception handling. Why don't you add code where the state is checked and log the DB name and value, so you can report on the same at the end of you job, like - "msdb state = X. Not backed up"? From the available values, I am unable to think what could the value of msdb be, to prevent backup, but still allow the job to run. Raj |
|||
|