I’m using powershell to automate the send logs file for a specific job in commvault.
I want send these logs to a specific local path in the server, but according to the this documents Send-CVLogFile (commvault.com) the available option is to email. So my question is, there’s another way using powershell or other api to do this?
Thanks.
Page 1 / 1
Hi @varsenia,
Thank you for your question! It does look like that built-in Powershell module is intended for sending e-mails, and doesn’t have a parameter for saving logs to an output location. I will suggest this as a potential enhancement to this function in a future release.
Although I don’t see a built-in API for doing this, I can offer a command line method that you can use inside your Powershell script. I have attached an XML here that you can use as a template for this.
First, you’ll need to modify the values in the XML. I have pre-populated with a lot of values. Some of these you may want to modify ahead of time, and some others you will need to update dynamically as part of your Powershell script. Any of the options you’d need to change will be in the <sendLogFileOption> element
A few elements you might want to change and leave permanently :
SaveToLogDir -- I currently have this going to /tmp (as I ran this from a Linux system). This is the output directory for where you want the sendLogFiles bundle to be written to on the CommServe.
csDatabase -- This is set to true, which specifies to collect the Commserv database. Set this to false if you do not wish to include a database.
getLatestUpdates -- This goes along with csDatabase. Setting this to true will perform a DR Backup first so that we collect the csDatabase as of that moment, and not the most reason DR Backup which could have been hours ago. This element can be removed if you opt to set csDatabase to false.
Now I also have a job ID in here already from my lab, which is in <multiJobIds>. This is something you’ll need to dynamically update each time your script runs, as this is the job ID it’s going to be collecting logs for. If you’re unfamiliar with using Powershell to modify the contents of an XML file, you can follow this as an example :
Simply add that to the XML in the same position, and it should give you what you’re looking for.
Let me know if it doesn’t work, or you have any other questions!
-Brian Bruno
Hi @Brian Bruno
Thank you very much, it’s working perfectly.
Can I have access to xml resources for other operation like backup and restore automation?
Hi @varsenia,
Absolutely! You can actually generate these XML’s yourself using the Java Console. The vast majority of operations in the UI have a ‘Save as script’ button, which is what I used to generate that XML. When you use Save as Script, there will be 2 files created :
A Batch (.bat) or Shell script (.sh) file (depending on whether or not you’re using a Windows or Linux Commserve) that performs the command line login to the CommServe, and executes the XML to perform the operation itself.
The XML file that defines the actual operation you wish to run.
To generate the XML that I shared with you, I simply opened the Send Log Files window in the UI with all the options selected that I wanted, and then clicked the ‘Save as Script’ button at the bottom :
Simply specify a location to save the scripts, and provide a file name with either the .bat or .sh extension.
The same location will also automatically create the .XML file in the same file path.
For example, if you wanted to get the XML to trigger a backup or a restore, you can use the same method by configuring that backup or restore the way you want in the UI, and you’ll find the same Save as Script button that you can leverage to obtain the underlying XML.
Any of those XML’s that you create using this method can all be executed the same way :
qoperation execute -af <Path\To\XML File>
This can be a powerful tool for getting the XML’s you need for automation.
-Brian Bruno
Hi @varsenia,
Absolutely! You can actually generate these XML’s yourself using the Java Console. The vast majority of operations in the UI have a ‘Save as script’ button, which is what I used to generate that XML. When you use Save as Script, there will be 2 files created :
A Batch (.bat) or Shell script (.sh) file (depending on whether or not you’re using a Windows or Linux Commserve) that performs the command line login to the CommServe, and executes the XML to perform the operation itself.
The XML file that defines the actual operation you wish to run.
To generate the XML that I shared with you, I simply opened the Send Log Files window in the UI with all the options selected that I wanted, and then clicked the ‘Save as Script’ button at the bottom :
Simply specify a location to save the scripts, and provide a file name with either the .bat or .sh extension.
The same location will also automatically create the .XML file in the same file path.
For example, if you wanted to get the XML to trigger a backup or a restore, you can use the same method by configuring that backup or restore the way you want in the UI, and you’ll find the same Save as Script button that you can leverage to obtain the underlying XML.
Any of those XML’s that you create using this method can all be executed the same way :
qoperation execute -af <Path\To\XML File>
This can be a powerful tool for getting the XML’s you need for automation.
-Brian Bruno
Hi @Brian Bruno,
Sorry for the delay, it works fine, so thank you for your time and support.