Library Table of Contents Index Previous Page (Alt-p) Next Page (Alt-n) Comments

Using the Run Command After Operation feature

SnapManager 2.1 for Microsoft SQL Server includes the ability to automatically run your own program or script after a backup or database verification operation finishes. This feature, called Run Command After Operation, is typically used to automatically archive a backup. See the following topics for more information:

How you can launch your own program or script  Top

When you start a SnapManager backup or database verification operation, you have the option to automatically run a command after the operation is finished. If you choose this option, you will be prompted to specify the following information before the backup or database verification operation can begin:

  1. The host system from which the command is to be run
  2. The full path of the command that you want SnapManager to run after the backup or database verification is finished
  3. Any parameters that are to be passed to the command

    Because the command (your own program or script) is invoked from within the context of a specific backup or database verification, you can pass the command information about the components of that operation. In your script, any occurrence of the text string %1 corresponds to the first parameter passed; the text string %2 corresponds to the second parameter, and so on.

After you have finished specifying the command and parameters, you can start the backup or database verification operation.

Note
The command or script is run only after a successful backup or verification. If the backup is not completed successfully, or if the verification fails, the command or script is not run.

Command arguments pass information to your program or script  Top

The Run Command After Operation feature supports the following variables, which can pass operation-specific information to your program or script.

Variable

Description

$SqlSnapshot

Expands to the name of an SQL Server database Snapshot copy.

Examples:

sqlsnap__winsrvr2__01-31-2005_15.03.09 
sqlsnap__winsrvr2__recent 

Note
The number of database Snapshot copies in a SnapManager backup set depends on the number of volumes used to store the databases included in the backup.

$InfoSnapshot

Expands to the name of a SnapInfo directory Snapshot copy.

Examples:

sqlinfo__winsrvr2__01-31-2005_15.03.09
sqlinfo__winsrvr2__recent 

$SnapInfoName

Expands to the name of the SnapInfo directory.

Examples:

WINSRVR2__recent 
WINSRVR2_11-23-2004_16.21.07__Daily

Note
If you use this variable, you must also provide the correct path to the directory.

$SnapInfoPath

Expands to the name of the SnapInfo subdirectory.

Example:

I:\SMSQL_SnapInfo\SQL__WINSRVR2\DB__Northwind 

$LogBackupFile

Expands to the full path name of the transaction log backup file.

Example:

I:\SMSQL_SnapInfo\SQL__WINSRVR2\DB__Northwind\L
ogBackup\ 11-01-2004_13.34.59__Northwind.TRB 

Note
Both the $SnapInfoPath and $LogBackupFile variables are automatically enclosed within double quotes so that the actual path name can contain spaces without affecting the script invocation on the Windows command-line. If you do not want the double quotes to appear in your command-line, remove them from the Command Arguments field in the Run Command After Operation window.

Command arguments are operation specific  Top

Each SnapManager operation that supports the Run Command After Operation feature (full backup, transaction log backup, and database verification) parses only the variables that apply to the operation as you have specified it.

The following table shows which of the command variables are available to the Run Command After Operation feature, depending on which SnapManager operation is used to invoke the feature.

Variable

SnapManager operation that is used to invoke the Run Command After Operation feature

Full backup1

Transaction log backup

Verification of full backup2

$SqlSnapshot

Parsed

--

Parsed

$InfoSnapshot

Parsed

Parsed

--

$SnapInfoName

Parsed

--

Parsed

$SnapInfoPath

Parsed

Parsed

Parsed

$LogBackupFile

Parsed3

Parsed

--

1Full backup: In the case of multiple databases, repeat the arguments passed for each database included in the backup.

2Verification of full backup: In the case of multiple databases, repeat the arguments passed for each database included in the verification. Additionally, variables are parsed and replaced with the most recent backup that is verified as part of this job.

3Full backup with the Run Transaction Log Backup option selected: The $LogBackupFile variable is parsed only when the transaction logs are backed up after full backup.

How to open the Run Command After Operation dialog box  Top

There are two ways to open the Run Command After Operation dialog box while starting or scheduling a backup or database verification operation.

From the Backup and Verification tab

To open the Run Command After Operation dialog box while specifying an operation in the Backup and Verification tab, complete the following steps.

Step

Action

1

Specify a full database backup, a transaction log backup, or a database verification.

2

Select the Run Command After Operation option.

3

Click Backup Now or Verify Now.

Result

The Run Command After Operation dialog box appears and displays the current default settings.

From the Backup Wizard

To open the Run Command After Operation dialog box while specifying an operation in the Backup Wizard, complete the following steps.

Step

Action

1

Step through the wizard screens to specify a full database backup, a transaction log only backup, or a database verification.

2

In the Run a Command After the Operation screen, do the following:

    1. Select the option labeled "Yes, run a command after this operation."
    2. Click Next.

Result

The Run Command After Operation dialog box appears and displays the current default settings.

Note
If you want to simply change the default values specified in the Run Command After Operation dialog box--without starting or scheduling a database backup, transaction log only backup, or database verification--you can open the Run Command After Operation dialog box from the Option menu. This is described in Run Command After Operation default settings.

Using the Run Command After Operation dialog box  Top

From within the context of a SnapManager backup or verification operation, you can use the Run Command After Operation dialog box to do the following:

Note
If you want to simply change the default values specified in the Run Command After Operation dialog box--without starting or scheduling a database backup, transaction log only backup, or database verification--you can open the Run Command After Operation dialog box from the Option menu. This is described in Run Command After Operation default settings.

To use the Run Command After Operation dialog box, complete the following steps.

Step

Action

1

Open the Run Command After Operation dialog box. For details, see How to open the Run Command After Operation dialog box.

2

In the "Specify a computer where..." box, enter or browse to the name of the host on which your program or script resides.

3

In the "Specify the full path..." box, browse to your program or script.

4

Form the command input string in the Command Arguments box. You can do this using any combination of the following methods:

  • To enter text directly into the Command Arguments box, click in the box and type the desired text.
  • To enter a SnapManager variable into the Command Arguments box, do the following:
    1. If necessary, click in the Command Arguments box to position the cursor.
    2. In the SnapManager Variables list, select the variable you want to enter.

      For more information, see Command arguments pass information to your program or script and Command arguments are operation specific.

    3. Click Select.

      Note
      Both the $SnapInfoPath and $LogBackupFile variables are automatically enclosed within double quotes so that the actual path name can contain spaces without affecting the script invocation on the Windows command-line. If you do not want the double quotes to appear in your command-line, remove them from the Command Arguments field in the Run Command After Operation dialog box.

5

Repeat Step 4 as needed until the Command Arguments box contains the arguments you want to pass to your program or script.

6

If you want to save the current settings as the new default values, select the Save as default option.

7

Click OK to apply your changes and close the Run Command After Operation dialog box.

Running a script from a UNC path on a Windows Server 2003 system  Top

If SnapManager is installed on a Windows Server 2003 system, then attempting to launch a script from a UNC (Uniform Naming Convention) path might cause SnapManager to hang. If this occurs, the log file shows no indication of the failure other than it is missing the last line of text: "The specified command has been launched successfully."

Windows Server 2003 ships with Internet Explorer's Enhanced Internet Explorer Security Configuration enabled. This setting is restrictive and prevents batch files located on a network share from running. The network location will need to be added to Internet Explorer's list of trusted sites.

To run a script from a UNC path on a Windows Server 2003 system, complete the following steps.

Step

Action

1

Log in to the Windows Server 2003 system that will be running the script.

  • This system can be the same system that is running SnapManager, or it can be a different server.
  • You must log on using the same user account that SnapManager is configured to use.

    For more information, see SnapManager service account requirements.

2

Launch Internet Explorer.

3

In the menu bar, select Tools > Internet Options.

Result

The Internet Options dialog box appears.

4

In the Internet Options dialog box, do the following:

    1. Select the Security tab.
    2. In the Security tab, select the Local intranet icon, and then click Sites.

Result

The Local Intranet dialog box appears.

5

In the Local Intranet dialog box, do the following:

    1. In the "Add this Web site to the zone" box, enter the host name of the machine from where the script will be launched.
    2. Click Add.

Result

The host name is added to the Web Sites list.

6

Click Close to close the Local Intranet dialog box.

7

Click OK to close the Internet Options dialog box.

8

To verify your changes, browse to the network location where the script resides and launch the script.

Result

The script should now run normally without security prompts.

Note
Although the script should run, it might actually fail to complete properly because the SnapManager variables are not be passed to the script in this test.

Library Table of Contents Index Previous Page (Alt-p) Next Page (Alt-n) Comments