Solved

Linux post restore script : restarting a service


Userlevel 1
Badge +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.

icon

Best answer by SparshGupta 16 August 2022, 09:55

View original

13 replies

Userlevel 7
Badge +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.

Userlevel 1
Badge +5

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

Userlevel 4
Badge +10

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 !!
 

Userlevel 7
Badge +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

Userlevel 4
Badge +10

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

Userlevel 1
Badge +5

@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.

Userlevel 1
Badge +5

@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.

Userlevel 2
Badge +7

@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”

 

 

Badge

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

Userlevel 1
Badge +5

@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.

Userlevel 1
Badge +5

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.

Userlevel 1
Badge +5

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>...

Userlevel 1
Badge +5

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