Skip to content

Commit

Permalink
Inspect mysql version before failing when restoring a snapshot, #1170 (
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewfrench committed Oct 12, 2018
1 parent c21e612 commit bf8eaea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
15 changes: 8 additions & 7 deletions docs/users/troubleshooting.md
Expand Up @@ -101,13 +101,14 @@ If you get a 404 with "No input file specified" (nginx) or a 403 with "Forbidden

Database snapshot from before v1.3.0 are not compatible with ddev v1.3+ because the mariabackup with MariaDB 10.2 is not compatible with earlier backups. However, if you really need that snapshot and don't have a database dump to run with `ddev import-db`, there's a fairly easy workaround:

1. In .ddev/config.yaml temporarily set `dbimage: drud/ddev-webserver:v1.2.0`.
2. `ddev start` to start with the new version
3. Use `ddev restore-snapshot` to restore the snapshot by name.
4. `ddev rm`
5. Remove the `dbimage` line from .ddev/config.yaml.
6. `ddev start`
7. Make a new snapshot with `ddev snapshot`.
1. In .ddev/config.yaml temporarily set `dbimage: drud/ddev-webserver:v1.2.0`
2. `ddev rm --remove-data` to remove an existing MariaDB 10.2 database
3. `ddev start` to start with the new version
4. Use `ddev restore-snapshot` to restore the snapshot by name
5. `ddev rm`
6. Remove the `dbimage` line from .ddev/config.yaml
7. `ddev start`
8. Make a new snapshot with `ddev snapshot`

## More Support

Expand Down
6 changes: 5 additions & 1 deletion pkg/ddevapp/ddevapp.go
Expand Up @@ -906,8 +906,12 @@ func (app *DdevApp) RestoreSnapshot(snapshotName string) error {
if !fileutil.FileExists(hostSnapshotDir) {
return fmt.Errorf("Failed to find a snapshot in %s", hostSnapshotDir)
}

if !fileutil.FileExists(filepath.Join(hostSnapshotDir, "db_mariadb_version.txt")) {
return fmt.Errorf("snapshot %s is not compatible with this version of ddev and mariadb. Please use the instructions at %s for a workaround to restore it", snapshotDir, "https://ddev.readthedocs.io/en/latest/users/troubleshooting/#old-snapshot")
// This command returning an error indicates grep has failed to find the value
if _, _, err := app.Exec("db", "sh", "-c", "mariabackup --version 2>&1 | grep '10\\.1'"); err != nil {
return fmt.Errorf("snapshot %s is not compatible with this version of ddev and mariadb. Please use the instructions at %s for a workaround to restore it", snapshotDir, "https://ddev.readthedocs.io/en/latest/users/troubleshooting/#old-snapshot")
}
}

if app.SiteStatus() == SiteRunning || app.SiteStatus() == SiteStopped {
Expand Down

0 comments on commit bf8eaea

Please sign in to comment.