craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.28k stars 634 forks source link

[4.x]: Couldn't backup db #15090

Closed Vandemonica closed 5 months ago

Vandemonica commented 5 months ago

What happened?

I'm preparing to upgrade my project into 5.x, however after I performed update to 4.9.5 the backup always failed whether it was the one on migrate/all or when I ran db/backup command

Backing up the database ... error: The shell command "mysqldump "--defaults-file"="C:\Users\Nircahya\AppData\Local\Temp\cvgbekafgzcc.cnf" "--add-drop-table" "--comments" "--create-options" "--dump-date" "--no-autocommit" "--routines" "--default-character-set"="utf8" "--set-charset" "--triggers" "--no-tablespaces" "--column-statistics"="0" "--no-data" "--result-file"="D:\Workspace\www\myproject\storage\backups\craftcms-myproject--2024-05-28-222447--v4.9.5.sql" "my_project_db" && mysqldump "--defaults-file"="C:\Users\Nircahya\AppData\Local\Temp\cvgbekafgzcc.cnf" "--add-drop-table" "--comments" "--create-options" "--dump-date" "--no-autocommit" "--routines" "--default-character-set"="utf8" "--set-charset" "--triggers" "--no-tablespaces" "--column-statistics"="0" "--no-create-info" "--ignore-table"="my_project_db.cs_assetindexdata" "--ignore-table"="my_project_db.cs_cache" "--ignore-table"="my_project_db.cs_imagetransformindex" "--ignore-table"="my_project_db.cs_resourcepaths" "--ignore-table"="my_project_db.cs_phpsessions" "--ignore-table"="my_project_db.cs_sessions" "my_project_db" >> 'D:\Workspace\www\myproject\storage\backups\myproject--2024-05-28-222447--v4.9.5.sql'" failed with exit code 1.
Aborting.

I couldn't find anything interesting in the logs but another thing to take a note is I was able to do backup normally on 4.7.1, let me know if I need to show something

Craft CMS version

Craft Solo 4.9.5

PHP version

8.2.19

Operating system and version

WINNT 10.0

Webserver and version

Nginx 1.22.1

Database type and version

MySQL 8.0.32

Image driver and version

GD 8.2.19

Installed plugins and versions

timkelty commented 5 months ago

@Vandemonica are you running this via DDEV, or something else?

Vandemonica commented 5 months ago

no, just the normal craft command, ran with windows 10 CMD

this one

php craft db/backup
angrybrad commented 5 months ago

@Vandemonica Sorry... does that mean Craft is installed on your native Windows host OS and you've installed Apache or are using IIS and MySQL on the host machine? i.e. no WSL, Lando, WAMP, etc.

I'm unable to reproduce with DDEV on Windows, so trying to get as close to your setup as possible.

Vandemonica commented 5 months ago

Kinda, I used Laragon with Nginx 1.22.1 as webserver

mmc501 commented 5 months ago

I have just upgraded to 4.9.5 from 4.8.something and I am getting the same issue when I try to run a backup. I also got the same on a Craft 5 installation.

2024-06-03 13:38:33 [web.ERROR] [yii\base\Exception] yii\base\Exception: Could not create backup: The shell command "mysqldump "--defaults-file"="C:\windows\TEMP\hoxexocbnxig.cnf" "--add-drop-table" "--comments" "--create-options" "--dump-date" "--no-autocommit" "--routines" "--default-character-set"="utf8" "--set-charset" "--triggers" "--no-tablespaces" "--single-transaction" "--column-statistics"="0" "--no-data" "--result-file"="C:\Websites\Sitename\storage\backups\iakoe--2024-06-03-123833--v4.9.5.sql" "sitename" && mysqldump "--defaults-file"="C:\windows\TEMP\hoxexocbnxig.cnf" "--add-drop-table" "--comments" "--create-options" "--dump-date" "--no-autocommit" "--routines" "--default-character-set"="utf8" "--set-charset" "--triggers" "--no-tablespaces" "--single-transaction" "--column-statistics"="0" "--no-create-info" "--ignore-table"="sitename.craft_assetindexdata" "--ignore-table"="sitename.craft_cache" "--ignore-table"="sitename.craft_imagetransformindex" "--ignore-table"="sitename.craft_resourcepaths" "--ignore-table"="sitename.craft_phpsessions" "--ignore-table"="sitename.craft_sessions" "sitename" >> 'C:\Websites\Sitename\storage\backups\iakoe--2024-06-03-123833--v4.9.5.sql'" failed with exit code 1. in C:\Websites\Sitename\vendor\craftcms\cms\src\controllers\UtilitiesController.php:226

Also running on windows, but just the default IIS & MySQL. I think this may be the issue:

"--defaults-file"="C:\windows\TEMP\hoxexocbnxig.cnf" I don't see that file existing.

When I remove that from the command and run it in a Command Window it backs up fine.

brandonkelly commented 5 months ago

Thanks @mmc501! We were able to reproduce, and have fixed it for the next release.

You can test by changing your craftcms/cms requirement in composer.json to 4.x-dev as 4.9.6 and running composer update.

mmc501 commented 5 months ago

Thanks @brandonkelly, tried that and issue is resolved. Thanks

brandonkelly commented 5 months ago

Thanks for confirming, @mmc501! Craft 4.9.7 and 5.1.9 are out now with that fix.