Conversation
Adds scripts/backup/transfer_backups.sh to SCP the nightly backups to a remote AWS host and delete each local copy only after its transfer is size-verified. Configuration (paths, host, SSH key) is supplied via an untracked backup_transfer.env; backup_transfer.env.example documents it. Authenticates with an SSH key rather than a password, since scp/ssh cannot take a password without leaking it into logs and the process list.
There was a problem hiding this comment.
Pull request overview
Adds a cron-friendly backup transfer utility that ships nightly backup artifacts to a remote AWS host over SSH/SCP, verifies each upload, and (optionally) deletes the local copy after verification.
Changes:
- Added
transfer_backups.shto load configuration from a local env file and transfer/verify backups one-by-one. - Added
backup_transfer.env.exampledocumenting required configuration variables. - Added a scoped
.gitignoreto keepbackup_transfer.env(secrets) out of version control.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| scripts/backup/transfer_backups.sh | Implements SCP transfer + remote size verification + optional local deletion, driven by backup_transfer.env. |
| scripts/backup/backup_transfer.env.example | Provides a template for required env variables and operational notes. |
| scripts/backup/.gitignore | Ignores the real backup_transfer.env file containing secrets. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Disable globbing while sourcing the env file (set -af) - Read local file size before scp so a rotated file is a per-file failure, not a full abort - Make logging resilient: an unwritable LOG_FILE warns and continues instead of killing the run under set -e - Add ConnectTimeout and pre-create the remote dir for cron reliability - Mark the script executable (100755)
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.
Overview
Adds
scripts/backup/transfer_backups.sh. It SCPs the nightly backups to a remote AWS host and deletes each local copy only after its transfer has been size-verified.Also adds:
backup_transfer.env.examplewhich documents the config (paths, host and SSH key).gitignorewhich keeps the realbackup_transfer.envwith the secrets out of gitAuth and safety
We use SSH key auth instead of a password, because scp and ssh can't take a password without leaking it into logs and the process list.
BatchMode=yesmakes it fail fast instead of hanging on a prompt when it runs from cron.A local backup is only deleted once the remote copy is confirmed present and matching in size. If a transfer fails the local file is kept and the script exits non-zero, so nothing gets lost.
Deploy steps (done on the server, not in this PR)
cp backup_transfer.env.example backup_transfer.envand fill in the real valueschmod 600on it and add its public half to the AWS box0 3 * * * /path/to/omniport-docker/scripts/backup/transfer_backups.sh