initial commit
Signed-off-by: Jason Hall <imjasonh@gmail.com>
This commit is contained in:
commit
4dc1b58f2f
20 changed files with 1398 additions and 0 deletions
16
scripts/backup.sh
Executable file
16
scripts/backup.sh
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
# Run on the VM via the forgejo-backup.timer systemd unit.
|
||||
# Snapshots the SQLite DB, tars the data dir, and uploads to GCS.
|
||||
# Note: the canonical copy of this script is embedded in cloud-init/user-data.yaml.tpl
|
||||
# at /var/lib/forgejo/backup.sh. This file is kept for readability and ad-hoc reuse.
|
||||
set -euo pipefail
|
||||
|
||||
: "${GCS_BACKUP_BUCKET:?GCS_BACKUP_BUCKET must be set}"
|
||||
|
||||
STAMP=$(date -u +%Y%m%dT%H%M%SZ)
|
||||
docker exec forgejo sqlite3 /data/gitea/gitea.db ".backup '/data/gitea/snapshot.db'"
|
||||
tar czf "/tmp/forgejo-${STAMP}.tar.gz" -C /mnt/disks/forgejo-data forgejo
|
||||
docker run --rm -v /tmp:/tmp google/cloud-sdk:slim \
|
||||
gsutil cp "/tmp/forgejo-${STAMP}.tar.gz" "gs://${GCS_BACKUP_BUCKET}/"
|
||||
rm "/tmp/forgejo-${STAMP}.tar.gz"
|
||||
docker exec forgejo rm -f /data/gitea/snapshot.db
|
||||
Loading…
Add table
Add a link
Reference in a new issue