Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[GOVCMS-4997] Introduced a script for DB restore #268

Merged

Conversation

barbun
Copy link
Contributor

@barbun barbun commented Jul 18, 2023

Issue

We currently operate under the assumption that the pre-deploy backup will be a restore point in the unlikely scenario where we notice data corruption or failures on a production site (eg. failed updates). Further to this assumption the process is assumed to just be a drush command to import the database again. The workflow and the limits of this process are neither tested nor documented.

Proposed solution

Introduce a db restore script as part of the scaffold tooling that is supported by functional and practical tests. The script should perform basic validation and allow one line restore command that accepts .sql, .sql.gz and .tar.gz backups.

Usage

../govcms-db-restore [path-to-file] e.g. vendor/govcms/govcms-tooling/scripts/deploy/govcms-db-restore /tmp/backup.tar.gz

BACKUP_FILE=$1
echo "[info]: Importing backup file..."

if [[ $BACKUP_FILE == *".sql" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be better if we staged it like:

  1. Extract the archive if required (reset BACKUP_FILE with the extracted location)
  2. Check the file size of the dump; if > 100m use mysql < 100m drush (or some other based on the testing).

Basically I think we should look to use raw mysql when we have large dbs to import, this will ultimately perform better than Drush will.

Copy link
Contributor

@steveworley steveworley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, we just need to change the base branch for the merge.

@steveworley steveworley changed the base branch from 9.x-develop to 10.x-develop October 17, 2023 23:08
@steveworley steveworley merged commit 1931407 into govCMS:10.x-develop Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants