Daily MySQL backup to Google Drive#850
Open
edwh wants to merge 1 commit into
Open
Conversation
- Add db-backup.sh script that dumps database with mysqldump, compresses with gzip, and uploads to Google Drive using rclone - Script reads DB_* and GDRIVE_* env vars from init process (cron doesn't inherit container env vars) - Automatically rotates backups, keeping only the last 7 daily backups on Google Drive - Silent/no-op if GDRIVE_BACKUP_FOLDER_ID not set (for dev environments) - Install default-mysql-client and rclone in production image - Schedule daily backup at 2am UTC via cron in Dockerfile.fly - Add startup.sh registration pattern to ensure backup job persists across container restarts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
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.



Summary
Implements automated daily MySQL backups uploaded to Google Drive via rclone. Backups run daily at 2am UTC and only the last 7 backups are retained.
Implementation Details
db-backup.sh: New script that:
--single-transactionand--quickfor consistent InnoDB snapshotsDockerfile.fly changes:
default-mysql-client(for mysqldump)0 2 * * * /usr/local/bin/db-backup.sh(2am UTC).fly/scripts/startup.sh changes:
Required Fly.io Secrets
The following secrets must be set in the Fly.io application for backups to work:
Getting Service Account Credentials
RCLONE_CONFIG_GDRIVE_SERVICE_ACCOUNT_CREDENTIALSNotes on Fly.io Secrets
RCLONE_CONFIG_GDRIVE_SERVICE_ACCOUNT_CREDENTIALSmust be the complete JSON key file (multi-line JSON is supported)drive.filescope to access shared foldersGDRIVE_BACKUP_FOLDER_IDis not set, the backup job silently exits (no errors in production if misconfigured)Test Plan
🤖 Generated with Claude Code