1. Home
  2. Docs
  3. Job Settings
  4. Backup Job
  5. Scripts
  6. CMD Scripts

CMD Scripts

CMD scripts are regular Windows shell scripts, such as batch files .bat. They are executed in the same server where the application is installed, on behalf of the service (typically using the Local System user by default).

When creating a script, please consider the following:

  • Any non-zero exit code will result in an error for this step in the job.
  • Conversely, even if there were errors within the script, if the last command in the script executed successfully, the job will not report any errors.

If you want to execute a PowerShell script, use powershell.exe and pass the script as an argument.

powershell.exe -File script.ps1

The following variables will be available in the script:

  • SQLBAK_BACKUP_TYPE (FULL, FULL_COPY, DIFF, TRAN_LOG, TRAN_LOG_COPY) – The backup type specified at the beginning of the backup job (set in the scheduler).
  • SQLBAK_JOB_SUCCESS(1 – Success, 0 – Failure) – A flag indicating the presence of errors in the backup job, available only in the After backup section.