Quick overview
This workflow runs nightly to back up GitHub repositories by downloading each repo as a tarball and uploading it to Amazon S3, then deletes older archives based on a retention window and emails a run report via SMTP.
How it works
- Runs every night at 02:00 on a schedule.
- Validates required settings like the S3 bucket, S3 prefix, retention days, and report email before doing any work.
- Uses the GitHub API to identify the authenticated account (or a specified owner) and lists all owned repositories with pagination.
- Downloads each repository as a GitHub tarball (retrying on failure) and uploads it to Amazon S3 with a timestamped filename under the configured prefix.
- Lists existing objects in the S3 prefix, selects backups older than the retention window, and deletes the expired archives.
- Builds a summary including successes, skipped empty repositories, failures, and deletions, then sends the report by email over SMTP.
Setup
- Add a GitHub API credential with access to the repositories you want to back up (including appropriate scopes for private repos).
- Add an AWS credential with permission to list, upload, and delete objects in your target S3 bucket, and set the bucket name and a dedicated prefix in the workflow settings.
- Add an SMTP credential for the email report and set the recipient (and optional sender) address in the workflow settings.
- Review and adjust the schedule time, then run the workflow manually once to confirm backups, retention cleanup, and email reporting work as expected.