Skip to main content

I have successfully set up a pre-scan command and it does what I want.

Now I also want it to output a line of information into any of the standard Commvault logs, so that it will appear when I right-click the job > View logs > For the job.

The command is simply a line of Windows CMD.exe instead of a script. This is for a NAS backup, using snapshots as the content source, and what the command does is find the most recent snapshot (a different pathname every time) and create a symbolic link to it (the same pathname every time).

But it would also be useful to record against the job, in Commvault logs, the name of the snapshot that was selected.

I tried adding a statement (echo “Using snapshot <snapshotname> for backup">&2) to see if it would get picked up, but what happened was the Pre-Scan phase hung and the command never completed.

Is there any file handle that the Commvault logger monitors on pre/post commands, or do I need to set up a custom logfile for this?

For anyone interested, the pre-scan command is:

C:\Windows\System32\cmd.exe /V:ON /C "(set NAS=\\mynas) & (set VOL=myvolume) & (for /F "usebackq" %S in (`dir /B /O:N %NAS%\%VOL%\.snapshot\%VOL%.????_??_??_00_0?`) do @set LASTSNAPSHOT=%S) && (mklink /D !NAS!\!VOL!\.backup_snapshot_link .snapshot\!LASTSNAPSHOT!)" /suppress

And the post-backup command is:

C:\Windows\System32\cmd.exe /C "rmdir \\mynas\myvolume\.backup_snapshot_link" /suppress

Good morning.  Commvault uses locks in our threads trying to bypass that could very well have unexpected results.  I would recommend setting up the custom log for this if possible.  Keep in mind that if Commvault needs to use a thread that another process is using or has a lock on, it will fail the operation in progress.  


I agree with Orazan, I have not seen a way to log anything other than the response or error codes from the Commvault command being run. So for a pre/post script what I have seen many do is to create a custom log file inside the CV Logs directory that your script writes to so that the logs can be collected easily by the backup teams via the standards Send Logs process or view logs process.


Thank you Orazan and Graham. To keep the line from getting ridiculously long I incorporated a custom logfile by changing it slightly like this:

C:\Windows\System32\cmd.exe /V:ON /C "(set NAS=\\mynas) & (set VOL=myvolume) & (for /F "usebackq" %S in (`dir /B /o:n !NAS!\!VOL!\.snapshot\!VOL!.????_??_??_??_??`) do @set LINKCMD=mklink /D !NAS!\!VOL!\.backup_snapshot_link .snapshot\%S) && (!LINKCMD!) && (echo %DATE% %TIME% !LINKCMD!>>"C:\Program Files\Commvault\ContentStore\Log Files\nas_snapshots.log")" -suppress


Note that should be “/suppress” not “-suppress” on the end, and the log entry works only in my test shell, not in the Commvault pre-command, so I’ll skip it and change it to a powershell script instead.

Just a bit paranoid about any script that’s called automatically being modified and trojaned, that’s why I wanted a self-contained command.


Reply