Advanced Scripting in BackupAssist
Contents: |
---|
How to write advanced scripts in BackupAssist with environment variables
BackupAssist offers a number of environment variables that you can easily incorporate into pre and post backup scripts.The following is a list of the variables currently available to BackupAssist
- %BACKUPASSIST_JOB_NAME%: the name of the backup job
- %BACKUPASSIST_JOB_DESC%: the description of this backup job
- %BACKUPASSIST_STATUS%: the status of the last backup where 0 means failure, and 1 means success
- %BACKUPASSIST_FILENAME%: the resultant filename of the backup (ie 2006-12-02.bkf)
- %BACKUPASSIST_MEDIA_LABEL%: the associated media label for the backup (ie Monday, Tuesday, Wednesday, Year, etc)
To input scripts into BackupAssist, please carry out the following:
1. Select the 'Advanced Tab' in BackupAssist
2. Select 'Modify scripts to run before and after the backup'
3. Manually enter scripts you wish to run before or after the backup process
Figure 1: Modifying Scripts in BackupAssist
An example Advanced Script with environment variables
The following sample script demonstrates how to execute different commands depending on whether a backup succeeded or failed.
@echo off
if %BACKUPASSIST_STATUS% == 0 goto ERROR_COMMANDS
:SUCCESS_COMMANDS
net send admin-desktop "Backup Completed Successfully"
goto END
:ERROR_COMMANDS
net send admin-desktop "Backup Failed"
:END
net send admin-desktop "Backup Operation has finished"
@REM ---> Backup succeeded. Insert commands here
@REM ---> Backup failed. Insert commands here
@REM ---> Insert any final commands here that are executed for both successful and failed backups.
Example Advanced Script for sending the backup to an FTP Server
The following sample script demonstrates how to use the free command-line utility NCFTP and the ncftpput command to upload your backup file to a FTP server, only if the backup is successful.
@echo off
if %BACKUPASSIST_STATUS% == 0 goto END
:SUCCESS_COMMANDS
"C:\Program Files\NCFTP\ncftpput" -u username -p password domainname.com /backups "%BACKUPASSIST_FILENAME%"
:END
net send admin-destkop "Backup Operation has finished - check the report for the status"
@REM ---> Backup succeeded so send the backup file to the FTP server
@REM ---> Insert any final commands here that are executed for both successful and failed backups.