-
-
Save josemmo/24e35f2b4984a4370ce2c164f5956437 to your computer and use it in GitHub Desktop.
# Based on this answer: https://stackoverflow.com/a/61859561/1956278 | |
# Backup old data | |
Rename-Item -Path "./data" -NewName "./data_old" | |
# Create new data directory | |
Copy-Item -Path "./backup" -Destination "./data" -Recurse | |
Remove-Item "./data/test" -Recurse | |
$dbPaths = Get-ChildItem -Path "./data_old" -Exclude ('mysql', 'performance_schema', 'phpmyadmin') -Recurse -Directory | |
Copy-Item -Path $dbPaths.FullName -Destination "./data" -Recurse | |
Copy-Item -Path "./data_old/ibdata1" -Destination "./data/ibdata1" | |
# Notify user | |
Write-Host "Finished repairing MySQL data" | |
Write-Host "Previous data is located at ./data_old" |
Great work. This works perfectly without errors or stress.
Perfect!
I confirm it still works!
This still works, thank you
thank you very much it still works!
Saved me! Thank you sooooooo much!
Thank you!
you can add a line at the beginning of the script to delete the existing "data_old" directory before creating a new backup.
# Delete existing data_old directory
Remove-Item -Path "./data_old" -Recurse -Force
Amazing ...
It's just awesome! Thanks very much!
Marvelous! Works beautifully.
thanks! as @Chanaka-J suggests adding that line helps in case you have to run it more than once
Thank you a thousand times.
This is amazing. Thank you!
Kudos. You're the best !
Golden!
Thank you guise, this has been such an annoying beast that comes around more than once. Interesting though this has been on the books for 4 years now and still going strong.
you can add a line at the beginning of the script to delete the existing "data_old" directory before creating a new backup.
# Delete existing data_old directory Remove-Item -Path "./data_old" -Recurse -Force
Great! worked!, thank you!