cancel
Showing results for 
Search instead for 
Did you mean: 

how to exclude sql database is offline state

T_N
Level 6

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

 

2 ACCEPTED SOLUTIONS

Accepted Solutions

puneet102
Level 4

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

Thanks
Puneet Dixit

View solution in original post

Michal_Mikulik1
Moderator
Moderator
Partner    VIP    Accredited Certified

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

View solution in original post

3 REPLIES 3

puneet102
Level 4

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

Thanks
Puneet Dixit

Michal_Mikulik1
Moderator
Moderator
Partner    VIP    Accredited Certified

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

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