How to trap failed backup command?

  • Hi all

    I am whipping up my own script for backups (diff, full and log) with emailing, compression and deletion of files X days long etc (I will post when complete).

    I am having problems trapping the BACKUP command on failure... ie:

    set @v_starttime = getdate()

    BACKUP DATABASE @p_database TO vxtmpdump WITH INIT, NAME = @p_database, NOSKIP , STATS = 10, DESCRIPTION = @v_filename, NOFORMAT

    if @@error > 0 then


    does not work, actually the script stops immediatly at the failure of the command. Is the only way to trap this error is by scheduling it as a job?



    Chris Kempster
    Author of "SQL Server Backup, Recovery & Troubleshooting"
    Author of "SQL Server 2k for the Oracle DBA"

  • You might try trapping using DTS. Enter this command in a T-SQL step and then setting succes and failure steps.

    Steve Jones

Viewing 2 posts - 1 through 2 (of 2 total)

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