git-trace

romele / git-trace public

62 commits · 1 branch · 1 tag · 1 contributor (top: Romele) · first commit 3d ago · last push 12m ago

deploy/backup.sh

#!/bin/sh
# git-trace nightly backup — two artifacts, both plain files.
# Install: crontab -e → 30 3 * * * /srv/git-trace/bin/backup.sh
set -e
D=/srv/git-trace
B=/srv/backups/git-trace
KEEP=${KEEP:-14}
mkdir -p "$B/db" "$B/repos"

# consistent snapshot of the DB (online-safe)
sqlite3 "$D/var/git-trace.db" ".backup '$B/db/gt-$(date +%F).db'"

# bare repositories are rsync-safe plain files
rsync -a --delete "$D/repos/" "$B/repos/"

# keep $KEEP daily DB snapshots
ls -1t "$B"/db/gt-*.db 2>/dev/null | tail -n +$((KEEP+1)) | xargs -r rm