How to Script the following using PowerCLI on a Linux VM:
ORACLE DB STOP -> TAKE VM SNAPSHOT -> ORACLE DB START
Invoke-VMScript Maybe???
Yes, if you have the VMware Tools installed, I would suggest Invoke-VMScript.
Invoke a bash script before and after the snapshot.
Depending on your Linux distro take care of sudo.
Do you have the commands to stop/start Oracle?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I need the scripts to run in the following sequence using Invoke-VMscript:
( \tmp\pre-script.sh > "new-snapshot -Name "Demo" -Memory" > \tmp\post-script.sh )
Basically it would be something like this.
But you might want to check if the script ran correctly. Do these shell script return something?
$vmName = 'YourOracleBox'
$cred = Get-Credential -Message "Enter your credentials for $($vmName)"
Invoke-VMScript -VM $vmName -ScriptType Bash -ScriptText '/tmp/pre-script.sh' -GuestCredential $cred
Get-VM -Name $vmName | New-Snapshot -Name 'Demo'
Invoke-VMScript -VM $vmName -ScriptType Bash -ScriptText '/tmp/post-script.sh' -GuestCredential $cred
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank You LucD, Finally..How can i use Wait-Task cmdlet to make it a completely Synchronous Operation.
Since you don't use the RunAsync switch anywhere, it should already be a synchronous.
Or do you mean something else?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am not very sure of the Synchronous ability of Non-PowerCLI commands.
# Pre-Script.sh
Output File confirmed
# New-Snapshot
Task End confirmed
#Post-Script.sh
....
You mean the shell scripts?
In those you will have to write a "wait" mechanism yourself, the Invoke-VMScript cmdlet has no way of knowing what happens in a shell background script/command.
An option is to run a separate shell script that checks the status (through an Invoke-VMScript in a loop for example).
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference