Skip to main content
Solved

Linux post restore script : restarting a service


Forum|alt.badge.img+5

Hi all,

This may be obvious to a more seasoned linux user but I had a task recently to apply a syslog filter file to many servers.  After testing the filter file successfully, I opted to use Commvault to deploy the filter file to the destination servers using the same path (which worked fine).

I included the command below to restart the rsyslog service after the restore in the Advanced > Pre/Post > Post Recovery Command and I checked the “Use local system account” option to run as root.

systemctl restart rsyslog.service

I received the error below:

Unable to run [systemctl] on the client. Internal Error [12345678] in CVSession while communicating with remote host [Remote system [RHEL8.domain.name]. Remote execute request returned error: [Executable file not found.].]. []

I did not find the answer at the reference documentation link below or on a general search so I thought this Q&A was relevant.

https://documentation.commvault.com/11.24/expert/12761_pre_processes_and_post_processes_advanced.html#add-pre-process-commands-and-post-process-commands-to-restore-jobs

I’m guessing I need to run that command from /sbin/bash or just use the full path to systemctl.  Ideally I’d like the result of the command be recorded in the restore job log and the status of the restore job.

The Commserve is ver 11.26 and the linux client is 11.24.

Best answer by SparshGupta

Hi @SLodge_IW 


Kindly disregard my previous comment. Could you try passing all arguments as quote? 

"/bin/bash" "-c" "systemctl restart rsyslog.service"


Thanks,
Sparsh

View original
Did this answer your question?

13 replies

Mike Struening
Vaulter
Forum|alt.badge.img+23

I found some internal cases with the same error.  Issue was caused by the shell not being added.

Note, I am copying the fix for the issue in the case, so the syntax might not fit yours perfectly:

Error message: Description: Unable to run [/tmp/sh hello.sh] on the client. 

In the beginning of the script I added the shell as "!/bin/bash" and my script got executed.

So first line of the script is as follows:

/tmp # cat hello.sh
#!/bin/bash
# test script
cd /etc
........

I think you need to tell the script which shell to use to run the script, I hope this helps.


Forum|alt.badge.img+5
  • Author
  • Byte
  • 23 replies
  • August 12, 2022

Thanks @Mike Struening.

I was hoping to enter a command without creating a local script. For example, in the post recovery command section enter:

!/bin/bash -c “systemctl restart rsyslog.service”

References:

https://linux.die.net/man/1/bash

https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Shell-Syntax

In the logs I can see the following:

CStartClientRestore::Initialize(192) - Restore task XML ...

<prePostOpts runPostWhenFail="0" preRecoveryCommand="" postRecoveryCommand="!/bin/bash -c &quot;systemctl restart rsyslog.service&quot;"><impersonation level="1"><user userName=""/></impersonation></prePostOpts>...

However the job goes to a pending state and shows this error:

Error Code: [7:74]
Description: Unable to run [!/bin/bash -c] on the client. Internal Error [150995005] in CVSession while communicating with remote host [Remote system [rhel8.domain.name]. Remote execute request returned error: [Executable file not found.].]. []
Source: commserve1, Process: startPrePostCmd


SparshGupta
Vaulter
Forum|alt.badge.img+10
  • Vaulter
  • 147 replies
  • August 16, 2022

Hi @SLodge_IW 

 

You cannot paste the commands directly under pre-post commands. You need to provide a script path and that script should contain the desired steps to be run.

 

@Sparsh - Please disregard this and check the latest comment !!
 


Onno van den Berg
Commvault Certified Expert
Forum|alt.badge.img+19

Yeah I think you will have to provide a s script. Funny fact is that the documentation is not so clear and also the definitions within the program are not consistent. Note the difference between backup and restore where they use process and command. Would make it way ,ore clear if they would just use the definition script. 

ttps://documentation.commvault.com/11.24/expert/12761_pre_processes_and_post_processes_advanced.html
 

@SLodge_IW this document contains more info around path definitions. 
https://documentation.commvault.com/11.24/expert/12782_pre_processes_and_post_processes_commands_and_arguments.html


SparshGupta
Vaulter
Forum|alt.badge.img+10
  • Vaulter
  • 147 replies
  • Answer
  • August 16, 2022

Hi @SLodge_IW 


Kindly disregard my previous comment. Could you try passing all arguments as quote? 

"/bin/bash" "-c" "systemctl restart rsyslog.service"


Thanks,
Sparsh


Forum|alt.badge.img+5
  • Author
  • Byte
  • 23 replies
  • August 16, 2022

@SparshGupta That worked perfectly. It showed up like this in the logs:

...<prePostOpts runPostWhenFail="0" preRecoveryCommand="" postRecoveryCommand="&quot;/bin/bash&quot; &quot;-c&quot; &quot;systemctl restart rsyslog.service&quot;"><impersonation level="1"><user userName=""/></impersonation></prePostOpts>...

And also here, showing the inferred args:

… main() - jobId 12345 - args = [ "-c" "systemctl restart rsyslog.service" -attempt 1 -status 1 -job 12345]

 

That’s the solution I was hoping for - thanks for helping 😀

 

Also I hope that others will find it useful.


Forum|alt.badge.img+5
  • Author
  • Byte
  • 23 replies
  • August 16, 2022

@Onno van den Berg , I did not find that commands and arguments reference so thank you for the link.  It explains the inferred arguments in the logs.


Forum|alt.badge.img+7
  • Vaulter
  • 62 replies
  • August 16, 2022

@SLodge_IW have you tried running the command without the “!” in !/bin/bash -c “systemctl restart rsyslog.service"  

Typically, all you need to specify is the location of bash.  Example run #whereis bash and then specify the location give /bin/bash -c “command” or /usr/bin/bash -c “command”

 

 


Forum|alt.badge.img
  • Vaulter
  • 1 reply
  • August 16, 2022

If you restored the script file to multiple servers, please also confirm that it has execute permissions on those servers.

# ls -al /your/script/file

rwx--x--x owner group filename

# chmod +x /your/script/file


Forum|alt.badge.img+5
  • Author
  • Byte
  • 23 replies
  • August 16, 2022
NVFD411 wrote:

@SLodge_IW have you tried running the command without the “!” in !/bin/bash -c “systemctl restart rsyslog.service"  

@NVFD411 No, I didn’t remove the “!” but from the log output between the failed attempts and the successful attempt, I suspect that the following inputs would also work because of how the first and following strings are parsed into script and arguments:

"/bin/bash" "-c systemctl restart rsyslog.service"

/bin/bash "-c" "systemctl restart rsyslog.service"

Edit: one succeeded, one failed; see below.


Forum|alt.badge.img+5
  • Author
  • Byte
  • 23 replies
  • August 16, 2022
bwalsh wrote:

If you restored the script file to multiple servers, please also confirm that it has execute permissions on those servers.

@bwalsh , I was trying to run a command without uploading a script in order to avoid having to handle file permissions.


Forum|alt.badge.img+5
  • Author
  • Byte
  • 23 replies
  • August 16, 2022

This version failed:

"/bin/bash" "-c systemctl restart rsyslog.service"

Logs:

main() - jobId 12345- remoteexename = [/bin/bash]
main() - jobId 12345- args = [ "-c systemctl restart rsyslog.service" -attempt 1 -status 1 -job 12345]

and

...<prePostOpts runPostWhenFail="0" preRecoveryCommand="" postRecoveryCommand="&quot;/bin/bash&quot; &quot;-c systemctl restart rsyslog.service&quot;"><impersonation level="1"><user userName=""/></impersonation></prePostOpts>...


Forum|alt.badge.img+5
  • Author
  • Byte
  • 23 replies
  • August 16, 2022

This version was successful:

/bin/bash "-c" "systemctl restart rsyslog.service"

Logs:

main() - jobId 12345- remoteexename = [/bin/bash]
main() - jobId 12345 - args = ["-c" "systemctl restart rsyslog.service" -attempt 1 -status 1 -job 12345]

and 

<prePostOpts runPostWhenFail="0" preRecoveryCommand="" postRecoveryCommand="/bin/bash &quot;-c&quot; &quot;systemctl restart rsyslog.service&quot;"><impersonation level="1"><user userName=""/></impersonation></prePostOpts>


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings