Files
eagle0/.github/workflows/gitea_backup.yml
T
adminandGitHub 809c1e256a Add encrypted offsite backups for Gitea (#8795)
* Add encrypted Gitea offsite backups

* Avoid Homebrew cleanup in Gitea backup

* Use dedicated Spaces credentials for Gitea backups

* Authenticate Gitea backups with a dedicated SSH key

* Use SCP for Synology Gitea backups

* Skip regenerable unreadable Gitea state

* Finalize scheduled Gitea backup workflow

* Group Gitea backup retention across runners
2026-07-26 21:23:17 -07:00

103 lines
3.6 KiB
YAML

name: Gitea Offsite Backup
on:
workflow_dispatch:
inputs:
full_restore_verify:
description: 'Download and validate a complete restored snapshot'
required: true
default: false
type: boolean
maintenance:
description: 'Apply retention and prune unreferenced Restic packs'
required: true
default: false
type: boolean
schedule:
- cron: '23 10 * * *'
- cron: '53 11 * * 0'
concurrency:
group: gitea-offsite-backup
cancel-in-progress: false
permissions:
contents: read
jobs:
backup:
if: (github.event_name == 'workflow_dispatch' && inputs.maintenance == false) || (github.event_name == 'schedule' && github.event.schedule == '23 10 * * *')
runs-on: [self-hosted, macOS, ARM64, halfdan]
timeout-minutes: 240
steps:
- name: Prepare non-LFS checkout
env:
GIT_CONFIG_GLOBAL: ${{ runner.temp }}/gitconfig-no-lfs
GIT_CONFIG_NOSYSTEM: '1'
run: |
git config --global --unset-all filter.lfs.process || true
git config --global filter.lfs.smudge "cat"
git config --global filter.lfs.clean "cat"
git config --global filter.lfs.required false
if [ -d ".git" ]; then
git config --local --unset-all filter.lfs.process || true
git config --local filter.lfs.smudge "cat"
git config --local filter.lfs.clean "cat"
git config --local filter.lfs.required false
fi
rm -f .git/hooks/post-checkout .git/hooks/post-merge .git/hooks/pre-push
- uses: actions/checkout@v7
env:
GIT_CONFIG_GLOBAL: ${{ runner.temp }}/gitconfig-no-lfs
GIT_CONFIG_NOSYSTEM: '1'
with:
persist-credentials: false
lfs: false
clean: false
- name: Back up Gitea
env:
DO_SPACES_ACCESS_KEY: ${{ secrets.GITEA_DO_SPACES_ACCESS_KEY }}
DO_SPACES_ENDPOINT: ${{ secrets.DO_SPACES_ENDPOINT }}
DO_SPACES_SECRET_KEY: ${{ secrets.GITEA_DO_SPACES_SECRET_KEY }}
FULL_RESTORE_VERIFY: ${{ inputs.full_restore_verify }}
GITEA_BACKUP_SSH_KEY: ${{ secrets.GITEA_BACKUP_SSH_KEY }}
RESTIC_PASSWORD: ${{ secrets.GITEA_RESTIC_PASSWORD }}
run: ./ci/github_actions/backup_gitea.sh backup
maintenance:
if: (github.event_name == 'schedule' && github.event.schedule == '53 11 * * 0') || (github.event_name == 'workflow_dispatch' && inputs.maintenance)
runs-on: [self-hosted, macOS, ARM64, halfdan]
timeout-minutes: 240
steps:
- name: Prepare non-LFS checkout
env:
GIT_CONFIG_GLOBAL: ${{ runner.temp }}/gitconfig-no-lfs
GIT_CONFIG_NOSYSTEM: '1'
run: |
git config --global --unset-all filter.lfs.process || true
git config --global filter.lfs.smudge "cat"
git config --global filter.lfs.clean "cat"
git config --global filter.lfs.required false
- uses: actions/checkout@v7
env:
GIT_CONFIG_GLOBAL: ${{ runner.temp }}/gitconfig-no-lfs
GIT_CONFIG_NOSYSTEM: '1'
with:
persist-credentials: false
lfs: false
clean: false
- name: Apply retention and verify repository
env:
DO_SPACES_ACCESS_KEY: ${{ secrets.GITEA_DO_SPACES_ACCESS_KEY }}
DO_SPACES_ENDPOINT: ${{ secrets.DO_SPACES_ENDPOINT }}
DO_SPACES_SECRET_KEY: ${{ secrets.GITEA_DO_SPACES_SECRET_KEY }}
GITEA_BACKUP_SSH_KEY: ${{ secrets.GITEA_BACKUP_SSH_KEY }}
RESTIC_PASSWORD: ${{ secrets.GITEA_RESTIC_PASSWORD }}
run: ./ci/github_actions/backup_gitea.sh maintenance