Feature/digital 721 backup restore s3 - #462
Open
jacobaaronyeager wants to merge 13 commits into
Open
Conversation
…erraform, strip cms/public prefix so files land in local Drupal layout, and surface aws errors. Add trap-based temp service-key cleanup to prevent leaked keys from exhausting the bucket key quota.
…to the local Lando site, handling the MySQL→MariaDB collation rewrite, container-relative import path, and a targeted s3fs uninstall. Delete the downloaded archive after -x extraction in download_files_common.sh and document the local refresh tooling in the README and backend docs.
… so they don't get downloaded every time, and added flags to force them
akf
requested changes
Jul 31, 2026
akf
left a comment
Contributor
There was a problem hiding this comment.
I'm looking forward to using this to refresh my local from prod. I'd like to see a couple of changes:
refresh-local.shhits an error on the sed command (see inline comment) and exits at that point.- The "files" backup includes a
phpdirectory that just has php cache_data. We don't want to back that up and transport it from one site to another. I see an easy way to delete it from the download before making a tar file, but I see a--excludeoption toaws s3 cpthat looks really promising.
| ## Cloud.gov runs MySQL 8, which emits the utf8mb4_0900_* collations and the | ||
| ## mysql_native_password plugin; local Lando runs MariaDB, which rejects them. | ||
| ## Rewrite those to MariaDB-compatible equivalents before importing. | ||
| sed -i '' \ |
Contributor
There was a problem hiding this comment.
I got an error from this sed command. The '' needs to be removed -- sed is taking it as the filename argument. (Maybe you have a variant sed implementation -- on linux, the suffix is optional with i so we don't need to specify an empty string to suppress backup files.)
| delete_s3_credentials "${SOURCE_SERVICE}" | ||
|
|
||
| date | ||
|
|
Contributor
There was a problem hiding this comment.
This would be a good spot to delete the php directory from the files bucket, if we can't just avoid downloading it in the first place.
…so the import works on Linux and macOS, Reject corrupt archives and dumps missing mysqldump's completion trailer, database-backup.sh: check exit codes, bound the tunnel wait, and verify the dump before upload so a partial one can't overwrite latest.sql.gz, Revoke the S3 service key and wipe local credentials via an EXIT trap
Contributor
Author
|
Updated! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira ticket
DIGITAL-721
Purpose
This adds:
Deployment and testing
Local Setup
You'll need to be logged into Cloud.gov and targeting the space you want to pull from:
No rebuild needed. If you want to try the local refresh, a working Lando site is enough.
QA/Testing instructions
New scripts in
/scriptspull backups from whatever space you have targeted (project and space are derived automatically):./scripts/download_files.sh— downloads the public files. Add-xto extract them intoweb/sites/default/files(thecms/public/prefix is stripped so they land where Drupal expects). Without-xyou just get the.tar.gz../scripts/download_static.sh— same, for the generated static site../scripts/refresh-local.sh— the one-step version: imports the DB, loads the files, uninstalls s3fs locally so images serve from disk, rebuilds cache, and hands you a login link. Use--no-db/--no-filesto run just one part,-d YYYY-MM-DDfor an older backup.To confirm: run
./scripts/refresh-local.sh, open the login link, and check that a page with uploaded images renders (images come fromsites/default/files, including thestyles/derivatives).Backup side: the "Daily backup" action now backs up the storage and static buckets alongside the database, and there's a "Files Restore" workflow to push them back. These run against prod on the scheduled job.
Note: loading a prod DB onto a feature branch can leave config/DB drift (e.g. a module the branch expects isn't enabled, or a
cimconflict on a changed field). That's expected — runlando drush cimyourself if you want your branch's config fully applied. The refresh script deliberately doesn't do that for you.Checklist for the Developer
Checklist for the Peer Reviewers