Skip to content

Add nightly backup transfer script - #55

Open
pelagiann wants to merge 2 commits into
masterfrom
feature/backup-scp-transfer
Open

pelagiann wants to merge 2 commits into
masterfrom
feature/backup-scp-transfer

Conversation

@pelagiann

Copy link
Copy Markdown

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.example which documents the config (paths, host and SSH key)
  • .gitignore which keeps the real backup_transfer.env with the secrets out of git

Auth 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=yes makes 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)

  1. Run cp backup_transfer.env.example backup_transfer.env and fill in the real values
  2. Place the SSH key, run chmod 600 on it and add its public half to the AWS box
  3. Add the cron entry to run at 3 AM:
    0 3 * * * /path/to/omniport-docker/scripts/backup/transfer_backups.sh

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.
Copilot AI review requested due to automatic review settings June 1, 2026 05:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.sh to load configuration from a local env file and transfer/verify backups one-by-one.
  • Added backup_transfer.env.example documenting required configuration variables.
  • Added a scoped .gitignore to keep backup_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.

Comment thread scripts/backup/transfer_backups.sh Outdated
Comment thread scripts/backup/backup_transfer.env.example Outdated
Comment thread scripts/backup/transfer_backups.sh
Comment thread scripts/backup/transfer_backups.sh
Comment thread scripts/backup/transfer_backups.sh Outdated
- 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)
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.

2 participants