When entering a Pre-process command or Post-process command, specify the full file path. For example, C:\users\profile.bat for Windows or /etc/pre.sh for UNIX. Do not use relative paths.
You can use spaces in commands and arguments provided they begin with an opening quotation mark and end with a closing quotation mark.
Examples
-
For generic pre-process and post-process commands, use the following syntax:
-
Windows
"c:\program files\test file\pre.bat"
OR
"c:\program files\test file\pre.bat" "test set"
OR
"c:\program files\test file\pre.bat" "one arg" "two arg"
-
UNIX
"/root/space cmd.sh"
OR
"/root/space cmd.sh" "one arg"
OR
"/root/space cmd.sh" "one arg" "two arg"
-
-
For a pre-process command or post-process command that is a batch file in Windows, use the command interpreter cmd.exe /C.
-
For PowerShell scripts, use the following syntax:
-
Windows
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command "powershell "C:\Pre_Post_Scripts\script.ps1" "arg1" "arg2""
-
UNIX
"/usr/bin/pwsh" $env:HOME='/root' "/opt/commvault/Base64/script.ps1" "arg1" "arg2"
-
Additional Arguments
In addition to the specified pre-process commands and Post-process commands, the CommServe sends additional arguments and appends them to the pre-process commands or post-process commands (if any). This can provide a useful means of control based on the type of job being run. You can use the value of the argument within pre-process or post-process batch files or scripts to run specific operations based on the level, number of attempts, or status of the job (for example, for UNIX by issuing an echo command or including a case statement within the appropriate script).
Note: You can prevent the additional arguments from being appended to the pre-process commands or post-process commands by adding /suppress to the end of the command, for example: "c:\program files\test file\pre.bat" "arg one" "arg two" /suppress.
These arguments include the following:
Argument |
Description |
Possible Values |
---|---|---|
--bkplevel |
A number representing the type of backup. |
|
-attempt |
The number of attempts for a pre-process and post-process within a given job. There is always at least one attempt. For example, if you want to run a pre-process and post-process on only the first time the job is attempted, you can test the value of the attempt argument received by the pre-process or post-process and take the appropriate action. |
Any number greater than one. |
-status |
A number representing the status of the phase that preceded a post-process within a job. This value is passed to all post-processes, but not pre-processes. For example, if you want to run a post-process only if the preceding phase was a success, you can test the value of the status argument received by the post-process and take the appropriate action. If there are no custom parameters, then the status is the sixth parameter sent to the post process. If there are additional parameters, then the system parameters are appended to the end of the custom parameters (if there are two custom parameters, then status would be the eighth parameter). With no additional parameters, the scenario described in this example can be handled in a Windows batch file as follows: Windows Batch Examples: Example: For backup operations
Example: For restore operations
Linux Shell Examples: Example: For backup operations:
Example: For restore operations:
|
1, the phase succeeded 2, the phase failed 3, the phase succeeded with one or more errors 4, the job was killed |
-job |
The job ID number received from Job Manager. |
The number representing the ID of a job. |