rust fmt, updated ci, hooks and docs

This commit is contained in:
nvrl committed 2026-06-15 17:08:46 +02:00
1 parent 8c120ae78d
commit a4c9b5bad1
39 files changed
+691 -902

No files matched your search

+23 -8
View File
@@ -1,7 +1,11 @@
#!/bin/bash
set -euo pipefail
# This script creates a full snapshot of the database and user media.
# Best run as a daily cron job.
# Full snapshot of the SQLite database + user media. Host-side and safe to run
# while the Rust backend has the DB open (WAL mode): uses `sqlite3 .backup`
# when available, otherwise an online copy via the same backend container.
# The Rust scheduler also runs backup_db on its own interval; this is the
# manual/cron supplement. Best run as a daily cron job.
ROOT_DIR=$(git rev-parse --show-toplevel)
cd "$ROOT_DIR"
@@ -10,6 +14,7 @@ TIMESTAMP=$(date +%Y%m%d_%H%M%S)
BACKUP_NAME="full_snapshot_$TIMESTAMP"
TEMP_DIR="backend/backups/$BACKUP_NAME"
FINAL_DEST="backend/backups"
DB_SRC="backend/db.sqlite3"
echo "========================================"
echo " Starting Full Project Backup... "
@@ -17,19 +22,29 @@ echo "========================================"
mkdir -p "$TEMP_DIR"
# 1. Run the database backup command
# 1. Database — consistent snapshot.
echo "Backing up database..."
docker exec holy-backend python manage.py backup_db --output "/app/backups/$BACKUP_NAME/db.sqlite3"
if command -v sqlite3 &>/dev/null; then
# Atomic, WAL-safe even with the backend holding the DB open.
sqlite3 "$DB_SRC" ".backup '$TEMP_DIR/db.sqlite3'"
else
# No host sqlite3: copy the DB plus its WAL sidecars so an in-flight WAL
# isn't lost. Install sqlite3 for a guaranteed-atomic snapshot.
echo " host sqlite3 not found — copying db + WAL sidecars"
cp "$DB_SRC" "$TEMP_DIR/db.sqlite3"
[ -f "$DB_SRC-wal" ] && cp "$DB_SRC-wal" "$TEMP_DIR/db.sqlite3-wal"
[ -f "$DB_SRC-shm" ] && cp "$DB_SRC-shm" "$TEMP_DIR/db.sqlite3-shm"
fi
# 2. Copy the media folder
# 2. Media.
echo "Backing up media..."
cp -r backend/media "$TEMP_DIR/media"
# 3. Create compressed archive
# 3. Compress.
echo "Compressing..."
tar -czf "$FINAL_DEST/$BACKUP_NAME.tar.gz" -C "backend/backups" "$BACKUP_NAME"
tar -czf "$FINAL_DEST/$BACKUP_NAME.tar.gz" -C "$FINAL_DEST" "$BACKUP_NAME"
# 4. Cleanup temp folder
# 4. Cleanup temp folder.
rm -rf "$TEMP_DIR"
echo ""