Forum Discussion

T_N's avatar
T_N
Level 6
7 years ago

how to exclude sql database is offline state

Hi All;

I have sql backup job failed because some sql database are "offline state", this backup policy is using tran script to backup sql database. What option can I exclude these database offline state to script ?

sql backup script :

SQLINSTANCE $ALL
OPERATION BACKUP 
DATABASE $ALL 
NBSERVER "xxxxx02" 
MAXTRANSFERSIZE 6 
BLOCKSIZE 7 
OBJECTTYPE TRXLOG 
NUMBUFS 2 
ENDOPER TRUE

 

Thank you

Tom

 

  • Try EXCLUDE <Database_Name> in script, For example, name of database is DATABASE1 then use the below script and check if the backup is working fine.

    SQLINSTANCE $ALL
    OPERATION BACKUP
    EXCLUDE DATABASE1 
    DATABASE $ALL 
    NBSERVER "xxxxx02" 
    MAXTRANSFERSIZE 6 
    BLOCKSIZE 7 
    OBJECTTYPE TRXLOG 
    NUMBUFS 2 
    ENDOPER TRUE
  • Hello,

    with script-based backups, you cannot simply exclude all offline databases with one phrase/keyword. You must name these databases explicitly. If you are on 7.7 client or above, you can use Intelligent MS SQL policies, which have attribute for this - Skip unavailable databases.

    Rgds

    Michal

3 Replies

Replies have been turned off for this discussion
  • Try EXCLUDE <Database_Name> in script, For example, name of database is DATABASE1 then use the below script and check if the backup is working fine.

    SQLINSTANCE $ALL
    OPERATION BACKUP
    EXCLUDE DATABASE1 
    DATABASE $ALL 
    NBSERVER "xxxxx02" 
    MAXTRANSFERSIZE 6 
    BLOCKSIZE 7 
    OBJECTTYPE TRXLOG 
    NUMBUFS 2 
    ENDOPER TRUE
    • Michal_Mikulik1's avatar
      Michal_Mikulik1
      Moderator

      Hello,

      with script-based backups, you cannot simply exclude all offline databases with one phrase/keyword. You must name these databases explicitly. If you are on 7.7 client or above, you can use Intelligent MS SQL policies, which have attribute for this - Skip unavailable databases.

      Rgds

      Michal

      • T_N's avatar
        T_N
        Level 6

        I think I will moveto  SQL intelligent policy, that allows me to exclude state "offline", thank you everyone.