Download deploy/backup.sh from EnergyVenom/patchwise-agent-studio: direct link, hf CLI and curl.
- Browser
- Download file 1.18 kB
-
https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/deploy/backup.sh
- Command line
-
hf download hf://spaces/EnergyVenom/patchwise-agent-studio/deploy/backup.sh
-
curl -L -o backup.sh https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/deploy/backup.sh
1.18 kB
| # Back up everything the application stores: database, secrets vault, encrypted evidence, reports, script library. | |
| # ./backup.sh [target-directory] (default: ./backups) | |
| # The archive contains the secrets vault, so store it encrypted and restrict who can read it. | |
| # Restore: stop the stack, then | |
| # docker run --rm -v patch-coworker_fpt-data:/data -v "$PWD/backups":/b alpine sh -c "rm -rf /data/* && tar -xzf /b/<file>.tar.gz -C /data" | |
| set -eu | |
| TARGET="${1:-./backups}" | |
| STAMP="$(date -u +%Y%m%dT%H%M%SZ)" | |
| mkdir -p "$TARGET" | |
| # A consistent copy of the SQLite database while the application keeps running. | |
| docker compose exec -T app python - <<'PY' | |
| import os, sqlite3 | |
| home = os.environ["FPT_HOME"] | |
| for name in ("fpt.sqlite", "checkpoints.sqlite"): | |
| src = os.path.join(home, name) | |
| if os.path.exists(src): | |
| with sqlite3.connect(src) as s, sqlite3.connect(src + ".backup") as d: | |
| s.backup(d) | |
| print("database snapshot written") | |
| PY | |
| docker run --rm -v patch-coworker_fpt-data:/data:ro -v "$(cd "$TARGET" && pwd)":/backup alpine \ | |
| tar -czf "/backup/patch-coworker-$STAMP.tar.gz" -C /data . | |
| echo "backup: $TARGET/patch-coworker-$STAMP.tar.gz" | |