Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Mysql: 'wrong' restore command #2714

Closed
ostark opened this issue Apr 10, 2018 · 0 comments
Closed

Mysql: 'wrong' restore command #2714

ostark opened this issue Apr 10, 2018 · 0 comments
Assignees

Comments

@ostark
Copy link
Contributor

ostark commented Apr 10, 2018

Description

I didn't know that we can use mysqldump to restore/import a MySQL database. I could not find anything in the official docs, just some rare answers on stack overflow.

In my tests the mysqldumpcommand gets executed without any errors, but it does nothing with the database. Maybe it works with a different version, I use the one from MariaDB.

Code

public function getDefaultRestoreCommand(): string
    {
        return 'mysqldump'.
            ' --defaults-extra-file="'.$this->_createDumpConfigFile().'"'.
            ' {database}'.
            ' < "{file}"';
    }

Fix

In my opinion it should be mysql {database} < {file} instead of mysqldump {database} < {file}.


Steps to reproduce

  1. Execute \Craft::$app->getDb()->backupTo('path/to/dump.sql');
  2. Change some data
  3. Execute \Craft::$app->getDb()->restore('path/to/dump.sql');
  4. Check if the new or the old data exist in the DB

Additional info

  • Craft version: 3.0.1
  • PHP version: 7.1
  • Database driver & version: mysql Ver 15.1 Distrib 10.1.14-MariaDB, for osx10.11 (x86_64) using readline 5.1
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants