juntekim.com/.github/workflows/weekly-k8s-backup.yml
Jun-te Kim 44ad2289ba mount
2025-12-14 00:32:14 +00:00

50 lines
No EOL
1.3 KiB
YAML

name: Weekly K8s Storage Backup
on:
schedule:
# Sunday 02:30 UTC (quiet time, predictable)
- cron: "30 2 * * 0"
workflow_dispatch:
jobs:
backup:
name: Backup /k8s_storage → S3
runs-on: mealcraft-runners
timeout-minutes: 180
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Sanity check mount
run: |
echo "Listing /k8s_storage:"
ls -lah /k8s_storage
ls -la
- name: Install AWS CLI (user-local)
run: |
if ! command -v aws >/dev/null 2>&1; then
echo "Installing AWS CLI locally..."
curl -s https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscliv2.zip
unzip -q awscliv2.zip
./aws/install \
--install-dir "$HOME/.aws-cli" \
--bin-dir "$HOME/bin"
echo "$HOME/bin" >> $GITHUB_PATH
fi
- name: Verify AWS identity
run: |
aws sts get-caller-identity
- name: Run backup
run: |
bash mist_infra/scripts/backup_k8s_storage_to_s3.sh
# example of restoring a back up
# aws s3 cp s3://mist-backups/2025-03-09/k8s_storage_mist_2025-03-09_02-30-01.tar.gz .
# sudo tar -xzf k8s_storage_*.tar.gz -C /home/kimjunte/k8s_storage