Discussions specific to the Microsoft Hyper-V hypervisor
Post Reply
suspect0
Novice
Posts: 6
Liked: never
Joined: Feb 25, 2016 2:10 pm
Full Name: John Kuntz
Contact:

Hot Backup of MySQL on Windows

Post by suspect0 »

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?

PTide
Product Manager
Posts: 5630
Liked: 550 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Hot Backup of MySQL on Windows

Post by PTide »

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.

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

Re: Hot Backup of MySQL on Windows

Post by suspect0 »

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

PTide
Product Manager
Posts: 5630
Liked: 550 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Hot Backup of MySQL on Windows

Post by PTide »

Please make sure that your script returns 0 (zero) or select Ignore script execution failures option.

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

Re: Hot Backup of MySQL on Windows

Post by suspect0 »

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.

PTide
Product Manager
Posts: 5630
Liked: 550 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Hot Backup of MySQL on Windows

Post by PTide »

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.

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

Re: Hot Backup of MySQL on Windows

Post by suspect0 »

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'

PTide
Product Manager
Posts: 5630
Liked: 550 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Hot Backup of MySQL on Windows

Post by PTide »

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.

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

Re: Hot Backup of MySQL on Windows

Post by suspect0 »

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

nmdange
Expert
Posts: 497
Liked: 127 times
Joined: Aug 20, 2015 9:30 pm
Contact:

Re: Hot Backup of MySQL on Windows

Post by nmdange »

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.

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

Re: Hot Backup of MySQL on Windows

Post by suspect0 »

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.

PTide
Product Manager
Posts: 5630
Liked: 550 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Hot Backup of MySQL on Windows

Post by PTide »

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.

AdamR
Novice
Posts: 4
Liked: never
Joined: Nov 04, 2013 11:42 am
Full Name: Adam
Contact:

Re: Hot Backup of MySQL on Windows

Post by AdamR »

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.

veremin
Product Manager
Posts: 17850
Liked: 1665 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Hot Backup of MySQL on Windows

Post by veremin »

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.

AdamR
Novice
Posts: 4
Liked: never
Joined: Nov 04, 2013 11:42 am
Full Name: Adam
Contact:

Re: Hot Backup of MySQL on Windows

Post by AdamR »

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 ?

veremin
Product Manager
Posts: 17850
Liked: 1665 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Hot Backup of MySQL on Windows

Post by veremin »

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 ?
I think initially it's been implemented that way to ease selection of appropriate files. Say, for pre/post-job activity you can easily select a needed ps script and, then, just add Powershell.exe at the beginning of the command to make everything work properly. (see here)

Most likely, that dialog form has been added to pre-freeze/post-thaw script window without changes. However, those scripts being injected inserted inside guests are quite different and the behaviour described about doesn't work any longer and can even lead to unintended consequences.

We do understand the confusion caused by that and plan to address it in the next product release by modifying that dialog.

Thanks.

felipemtz
Service Provider
Posts: 2
Liked: never
Joined: Jun 29, 2019 1:24 am
Full Name: Felipe Martinez Chavez
Contact:

Re: Hot Backup of MySQL on Windows

Post by felipemtz »

Is there an specific way to backup up MySQL on Windows 2012 VM? all Veeam documents for MySQL apply to MySQL on Linux VM. There are no scripts or bat files for Windows Server to freeze MySQL.

PTide
Product Manager
Posts: 5630
Liked: 550 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Hot Backup of MySQL on Windows

Post by PTide »

Hi,

The basic idea behind the backup is the same - flush tables with read lock and take a VM snapshot afterwards, then release the lock. It doesn't really matter whether the database is on Windows or on Linux, you only might need to adjust syntax of those scripts so that they apply for Windows installations.

Thanks!

Post Reply

Who is online

Users browsing this forum: bhead and 13 guests