Hot Backup of MySQL on Windows

Hyper-V specific discussions

Hot Backup of MySQL on Windows

Veeam Logoby suspect0 » Thu Feb 25, 2016 2:23 pm

I've already reviewed the procedure for backing up MySQL on Linux. However I'm trying to backup MySQL on Windows inside Hyper-V. I have a Powershell script to stop the MySQL Service, but it doesn't appear to be working:

Code: Select all
# Get the MySQL Service
# This is specifically named after the instance I think, so it could be different per server
$Service = Get-Service MySQL*

# If the Service is Running, Stop the service.
do {Stop-Service $Service -Force -PassThru; sleep 30; $ct = $ct + 1} while (($Service.Status -ne "Stopped") -and ($ct -lt 4))


The script is stored on the Veeam Backup Server, it is not signed. Any suggestions or other ways to go about this?
suspect0
Novice
 
Posts: 6
Liked: never
Joined: Thu Feb 25, 2016 2:10 pm
Full Name: John Kuntz

Re: Hot Backup of MySQL on Windows

Veeam Logoby PTide » Thu Feb 25, 2016 2:55 pm

Hi and welcome to the community!

Your pre-job script is trying perform all actions specified on your Veeam Backup Server, i.e. it tries to stop MySQL service on you VBR not on Windows guest. You need to you edit the script so that it connects to the remote MySQL server and stops it.

Thank you.
PTide
Veeam Software
 
Posts: 3017
Liked: 245 times
Joined: Tue May 19, 2015 1:46 pm

Re: Hot Backup of MySQL on Windows

Veeam Logoby suspect0 » Thu Feb 25, 2016 4:33 pm

Ok, changed the script to call the computername, ran it locally in powershell and confirmed it works.

Code: Select all
# Get the MySQL Service
# This is specifically named after the instance I think, so it could be different per server
$Service = Get-Service -ComputerName "<COMPUTER NAME HERE>" MySQL*

# If the Service is Running, Stop the service.
do {Stop-Service $Service -Force -PassThru; sleep 30; $ct = $ct + 1} while (($Service.Status -ne "Stopped") -and ($ct -lt 4))



However when I run the backup job manually it still fails. I also changed both powershell Execution policies on the Veeam Server and the target to Bypass.

Image
suspect0
Novice
 
Posts: 6
Liked: never
Joined: Thu Feb 25, 2016 2:10 pm
Full Name: John Kuntz

Re: Hot Backup of MySQL on Windows

Veeam Logoby PTide » Thu Feb 25, 2016 4:45 pm

Please make sure that your script returns 0 (zero) or select Ignore script execution failures option.
PTide
Veeam Software
 
Posts: 3017
Liked: 245 times
Joined: Tue May 19, 2015 1:46 pm

Re: Hot Backup of MySQL on Windows

Veeam Logoby suspect0 » Thu Feb 25, 2016 4:56 pm

Thank you, I checked the option to ignore failures and the VM got backed up. However I never see in the event log of the target system that it stops and/or starts the MySQL Service.
suspect0
Novice
 
Posts: 6
Liked: never
Joined: Thu Feb 25, 2016 2:10 pm
Full Name: John Kuntz

Re: Hot Backup of MySQL on Windows

Veeam Logoby PTide » Thu Feb 25, 2016 5:15 pm

Please make sure that you've specified valid guest OS credentials, the account that is used for script execution have to have enough permissions in guest OS.

Thank you.
PTide
Veeam Software
 
Posts: 3017
Liked: 245 times
Joined: Tue May 19, 2015 1:46 pm

Re: Hot Backup of MySQL on Windows

Veeam Logoby suspect0 » Wed Mar 09, 2016 1:52 pm

Alright, I switched the guest credentials even though the Veeam Service account has enough privileges. Even though I changed the credentials it continues to use the veeamsvc account. And Still fails


Code: Select all
[ScriptInvoker] Running Windows script 'C:\Scripts\Stop_Service.ps1'
[09.03.2016 07:59:14] <10> Info     VSSControl: Exec process in guest. C:\Scripts\Stop_Service.ps1. Timeout: 600
[09.03.2016 07:59:14] <10> Error    [ScriptInvoker] Failed to execute script in win guest machine. Script path: C:\Scripts\Stop_Service.ps1.
[09.03.2016 07:59:14] <10> Error    Failed to execute app in guest.
[09.03.2016 07:59:14] <10> Error    Failed to create process [\\<IP ADDRESS>\ADMIN$\{da6f73de-881e-4f1e-8bed-e9b1807e4bf4}\Stop_Service.ps1] as user: <DOMAINNAME>\veeamsvc
[09.03.2016 07:59:14] <10> Error    Win32 error: Code: 193 (System.Runtime.InteropServices.COMException)
[09.03.2016 07:59:14] <10> Error       at VeeamGuestHelperCtrlLib.GuestOperationsProviderClass.ExecApp(String pLocalPath, Int32 timeoutInSec, Boolean& pTimeoutOccurred, String userName, String pass)
[09.03.2016 07:59:14] <10> Error       at Veeam.Backup.VssProvider.CVssControlLocal.ExecProcessInGuest(String appLocalPath, Int32 timeoutInSec, Boolean& timeoutOccurred, CCredentials creds)
[09.03.2016 07:59:14] <10> Error       at Veeam.Backup.VssProvider.CVssControl.ExecProcessInGuest(String appLocalPath, TimeSpan timeout, CCredentials creds, Boolean& timeoutOccurred)
[09.03.2016 07:59:14] <10> Error       at Veeam.Backup.Core.CWinGuestScriptInvoker.ExecScript(String localPath, TimeSpan timeout, CCredentials creds, Int32& exitCode)
[09.03.2016 07:59:14] <10> Info     [ScriptInvoker] Script finished with exit code = '-1'
suspect0
Novice
 
Posts: 6
Liked: never
Joined: Thu Feb 25, 2016 2:10 pm
Full Name: John Kuntz

Re: Hot Backup of MySQL on Windows

Veeam Logoby PTide » Wed Mar 09, 2016 2:42 pm

Failed to create process [\\<IP ADDRESS>\ADMIN$\{da6f73de-881e-4f1e-8bed-e9b1807e4bf4}\Stop_Service.ps1] as user: <DOMAINNAME>\veeamsvc


Please make sure you can connect to the admin share with the same credentials as provided to Veeam Backup & Replication for VSS (veeamsvc)

If you can then please open a case with our support team and post your case ID in this thread.

Thank you.
PTide
Veeam Software
 
Posts: 3017
Liked: 245 times
Joined: Tue May 19, 2015 1:46 pm

Re: Hot Backup of MySQL on Windows

Veeam Logoby suspect0 » Wed Mar 09, 2016 2:47 pm

Yep, If i manually type \\IP ADDRESS\$ADMIN and log in with the veeamsvc account I can get right to it.

I'll open a case
suspect0
Novice
 
Posts: 6
Liked: never
Joined: Thu Feb 25, 2016 2:10 pm
Full Name: John Kuntz

Re: Hot Backup of MySQL on Windows

Veeam Logoby nmdange » Wed Mar 09, 2016 9:12 pm

I think you need to run the script in Veeam as "powershell.exe -command '.\Stop_Service.ps1'"

A .ps1 file is not an executable by itself.
nmdange
Expert
 
Posts: 191
Liked: 57 times
Joined: Thu Aug 20, 2015 9:30 pm

Re: Hot Backup of MySQL on Windows

Veeam Logoby suspect0 » Thu Mar 10, 2016 2:03 pm

didn't work. Veeam complained that it "couldn't find the script file"

Tried both powershell.exe -command (which should be used to execute a command I believe not a script) and also powershell.exe -file.
suspect0
Novice
 
Posts: 6
Liked: never
Joined: Thu Feb 25, 2016 2:10 pm
Full Name: John Kuntz

Re: Hot Backup of MySQL on Windows

Veeam Logoby PTide » Thu Mar 10, 2016 4:07 pm

didn't work. Veeam complained that it "couldn't find the script file"
You should either use an absolute path to your script or perform "cd C:\script-dir" prior to calling the script.

Please try the following:

1. Place you PS script to your MySQL VM
2. Create .bat that calls your PS script
3. Specify that .bat as a pre-freeze script in you backup job settings

Another approach is to rewrite your MySQL stopping script to .bat format.

Thank you.
PTide
Veeam Software
 
Posts: 3017
Liked: 245 times
Joined: Tue May 19, 2015 1:46 pm

Re: Hot Backup of MySQL on Windows

Veeam Logoby AdamR » Fri Jun 17, 2016 2:44 pm

I have the same problem. I can not run the script PS1 in the Pre-freeze setings to stop and start DB in guest OS.
To test out trying to run the script PS1 witch has only one simple command
write-host "TEST"

I know I can write a BAT script and its stop and start service but if it is possible to choose on the Veeam Backup Server other types of scripts than BAT (PS1, VBS, etc.) it should also work.
I prefer scripts PS1 and do not want to use the other.


Does anyone from the company Veeam can describe the requirements to be able to run PowerShell scripts, in the manual is not too much information about it.
AdamR
Novice
 
Posts: 4
Liked: never
Joined: Mon Nov 04, 2013 11:42 am
Full Name: Adam

Re: Hot Backup of MySQL on Windows

Veeam Logoby v.Eremin » Tue Jun 21, 2016 2:20 pm

Usage of bat format is required for pre-freeze/post-thaw scripts. So, you need to convert your PS script to bat file (there are several articles in internet describing how you can do that) or copy the necessary PS files inside guest manually and leave just a few lines in bat file. Those will be needed to execute already copied scripts.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 966 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Hot Backup of MySQL on Windows

Veeam Logoby AdamR » Wed Jun 22, 2016 10:00 am

I do not understand some of that, if properly run only BAT scripts is what purpose you can select other types of PS1, VBS, JS ?
AdamR
Novice
 
Posts: 4
Liked: never
Joined: Mon Nov 04, 2013 11:42 am
Full Name: Adam

Next

Return to Microsoft Hyper-V



Who is online

Users browsing this forum: No registered users and 8 guests