- GDRIVE_MIRROR_BOOT.md med staleness-varsel (12t terskel) og connector-prioritet - sync-gdrive-mirror.sh: auto-tidsstempel, prosjektindeks, .gdrive-mirror-state - osvauco-opax-boot.sh: alias auto-inject ~/.bashrc, GitHub vs lokal HEAD, PROMPT_COMMAND terminal-logging - opax-logg-slutt.sh standalone - .github/workflows/backup-gdrive-nightly.yml: nattlig git bundle + nøkkelfiler til GDrive - docs/GDRIVE_SETUP.md: ett-gangs oppsett-guide for rclone + IAM - docs/TODO.md: IAM/secrets-oppsett + gemini TUI-logging som neste oppgaver
92 lines
3.9 KiB
YAML
92 lines
3.9 KiB
YAML
name: Nightly GDrive Backup
|
|
|
|
# Kjører kl 03:00 UTC (05:00 CEST) hver natt + ved push til main
|
|
on:
|
|
schedule:
|
|
- cron: '0 3 * * *'
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch: # manuell trigger fra GitHub UI
|
|
|
|
jobs:
|
|
backup:
|
|
name: Backup OSVauco → Google Drive
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 15
|
|
|
|
steps:
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0 # full historikk for git bundle
|
|
|
|
# ── 1. Installer rclone ───────────────────────────────────────────────
|
|
- name: Install rclone
|
|
run: |
|
|
curl https://rclone.org/install.sh | sudo bash
|
|
rclone version
|
|
|
|
# ── 2. Konfigurer rclone med GDrive service account ───────────────────
|
|
# Forutsetter at RCLONE_GDRIVE_SA_JSON er lagt inn som GitHub Secret
|
|
# og at GDRIVE_BACKUP_FOLDER_ID peker på riktig GDrive-mappe
|
|
- name: Configure rclone
|
|
env:
|
|
RCLONE_GDRIVE_SA_JSON: ${{ secrets.RCLONE_GDRIVE_SA_JSON }}
|
|
GDRIVE_FOLDER_ID: ${{ secrets.GDRIVE_BACKUP_FOLDER_ID }}
|
|
run: |
|
|
mkdir -p ~/.config/rclone
|
|
cat > ~/.config/rclone/rclone.conf << EOF
|
|
[gdrive]
|
|
type = drive
|
|
scope = drive
|
|
service_account_credentials = ${RCLONE_GDRIVE_SA_JSON}
|
|
root_folder_id = ${GDRIVE_FOLDER_ID}
|
|
EOF
|
|
|
|
# ── 3. Nøkkelfiler (MD-indeks) → GDrive/vauco-mirror/ ─────────────────
|
|
- name: Sync key docs to GDrive mirror folder
|
|
run: |
|
|
rclone copy docs/AGENT_RULEBOOK.md gdrive:vauco-mirror/
|
|
rclone copy docs/GDRIVE_MIRROR_BOOT.md gdrive:vauco-mirror/
|
|
rclone copy docs/LEARNINGS.md gdrive:vauco-mirror/
|
|
rclone copy docs/VAUCO_OS_ROADMAP.md gdrive:vauco-mirror/
|
|
rclone copy docs/TODO.md gdrive:vauco-mirror/
|
|
rclone copy MASTERPLAN.md gdrive:vauco-mirror/
|
|
rclone copy protocols/sessions/index.md gdrive:vauco-mirror/sessions/
|
|
echo "[backup] Nøkkelfiler synkronisert → GDrive/vauco-mirror/"
|
|
|
|
# ── 4. Full repo-backup som git bundle → GDrive/vauco-backup/ ─────────
|
|
- name: Create git bundle
|
|
run: |
|
|
TIMESTAMP=$(date '+%Y-%m-%dT%H%M')
|
|
BUNDLE_NAME="OSVauco-backup-${TIMESTAMP}.bundle"
|
|
git bundle create "/tmp/${BUNDLE_NAME}" --all
|
|
echo "BUNDLE_NAME=${BUNDLE_NAME}" >> $GITHUB_ENV
|
|
echo "[backup] Bundle opprettet: ${BUNDLE_NAME}"
|
|
|
|
- name: Upload bundle to GDrive
|
|
run: |
|
|
rclone copy "/tmp/${{ env.BUNDLE_NAME }}" gdrive:vauco-backup/
|
|
echo "[backup] Bundle lastet opp → GDrive/vauco-backup/${{ env.BUNDLE_NAME }}"
|
|
|
|
# ── 5. Rydd gamle bundles (behold siste 7) ────────────────────────────
|
|
- name: Prune old bundles (keep last 7)
|
|
run: |
|
|
rclone ls gdrive:vauco-backup/ \
|
|
| sort -k2 \
|
|
| head -n -7 \
|
|
| awk '{print $2}' \
|
|
| xargs -I{} rclone deletefile gdrive:vauco-backup/{} || true
|
|
echo "[backup] Gamle bundles ryddet (behold 7 siste)"
|
|
|
|
# ── 6. Sammendrag ─────────────────────────────────────────────────────
|
|
- name: Summary
|
|
run: |
|
|
echo "=== BACKUP FERDIG ==="
|
|
echo "Tidspunkt : $(date '+%Y-%m-%dT%H:%M %Z')"
|
|
echo "Bundle : ${{ env.BUNDLE_NAME }}"
|
|
echo "Mirror : GDrive/vauco-mirror/ (nøkkelfiler)"
|
|
echo "Backup : GDrive/vauco-backup/ (git bundle)"
|
|
rclone ls gdrive:vauco-backup/ | sort -k2 | tail -7
|