craftcms / cms

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

beta.3 fails db update on particular server #1362

Closed narration-sd closed 7 years ago

narration-sd commented 7 years ago

Description

Couldn’t backup the database. How would you like to proceed? --- nice and appreciated message here Occurs on DO/Docker droplet, while update works fine on Vagrant vm

Steps to reproduce

  1. compose update to get vendor sources up-to-date with beta.3
  2. rsync the full site up to replace working beta.2 site
  3. use admin introducer to reach database update dialog
  4. fails with message above

Additional info

brandonkelly commented 7 years ago

This happens if mysqldump (or pg_dump if using PostgreSQL) isn’t available, which Craft 3 relies on for creating DB backups.

If it can’t be added, then you can open up config/general.php and add this:

'backupCommand' => false,
narration-sd commented 7 years ago

Ok, that makes good sense, and thanks as always for being right there on a point.

What I should do is add mysqldump to the Docker container for php – not there consequence of slim provisioning.

Will close when I get that done – must be later.

angrybrad commented 7 years ago

And because it isn't documented yet, here's the full docblock for that config setting:

/**
 * Craft will use the command line libraries `pg_dump` and `mysqldump` for backing up a database
 * by default.  It assumes that those libraries are in the $PATH variable for the user the web server is
 * running as.
 *
 * If you want to use some other library, or want to specify an absolute path to them,
 * or want to specify different parameters than the default, or you want to implement some other backup
 * solution, you can override that behavior here.
 *
 * There are several tokens you can use that Craft will swap out at runtime:
 *
 *     * `{path}` - Swapped with the dynamically generated backup file path.
 *     * `{port}` - Swapped with the current database port.
 *     * `{server}` - Swapped with the current database host name.
 *     * `{user}` - Swapped with the user to connect to the database.
 *     * `{database}` - Swapped with the current database name.
 *     * `{schema}` - Swapped with the current database schema (if any).
 *
 * This can also be set to `false` to disable database backups completely.
 */
narration-sd commented 7 years ago

great stuff, thanks, Brad.

Not sure why this wasn't clear in the logs anyway as a cause, just a seeming blind web app fail?

But when you get to it, among the thousands...or if I missed the requisite line...

C.

narration-sd commented 7 years ago

Ok, turned out this just needed adding mariadb-client package to the php-fpm container docker-compose file - built and up in seconds, and immediately worked with the update database dump.

The update itself killed my plugins, some triviata there no doubt also easy to find.

I do have one question, though -- couldn't work out how you get the database user/password added into the sqldump command, which is missing this as it's built.

Closed this was already by Brandon, so I'll email this query, as don't think you'll see it.

narration-sd commented 7 years ago

...and the plugins problem was due to the Windows junction => link in vendor being replicated exactly as a soft link from the dev machine, which isn't correct.

What's needed is an rsync -L, which translates to an ansible synchronize copy_links: yes

All done, beta 3 on a Dockered DO droplet as well.

angrybrad commented 7 years ago

@narration-sd if you leave the backupCommand set to null (default behavior), then you can see the default parameters Craft will pass into mysqldump here: https://github.com/craftcms/cms/blob/develop/src/db/mysql/Schema.php#L138

Credential are passed in through --defaults-extra-file, which creates a tmp file using the credentials you supplied to Craft to connect to the database.

narration-sd commented 7 years ago

Ah, slipped over that first parameter when looked at it -- eyes too quick. Makes sense and closure.

Thanks, Brad, as ever, and great to know you look at comments after issue closed -- seems most close out even their notification. But this is P&T...