Add daily automatic database backup to GitHub
- Remove data/ from .gitignore (keep WAL/SHM excluded) - Add backup.sh script: commits and pushes DB changes daily - Cron job at 3:00 AM: /var/www/html/dispensa/backup.sh - Include initial database snapshot
This commit is contained in:
+3
-2
@@ -1,8 +1,9 @@
|
|||||||
# Environment variables (secrets)
|
# Environment variables (secrets)
|
||||||
.env
|
.env
|
||||||
|
|
||||||
# SQLite database
|
# SQLite WAL/SHM temp files
|
||||||
data/
|
data/*.db-wal
|
||||||
|
data/*.db-shm
|
||||||
|
|
||||||
# SSL CA cert (local only)
|
# SSL CA cert (local only)
|
||||||
ca.crt
|
ca.crt
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Daily backup of Dispensa database to GitHub
|
||||||
|
# Runs via cron: commits and pushes data/dispensa.db
|
||||||
|
|
||||||
|
cd /var/www/html/dispensa || exit 1
|
||||||
|
|
||||||
|
# Only commit if there are actual changes
|
||||||
|
if git diff --quiet data/ 2>/dev/null && git diff --cached --quiet data/ 2>/dev/null; then
|
||||||
|
# Check for untracked files in data/
|
||||||
|
if [ -z "$(git ls-files --others --exclude-standard data/)" ]; then
|
||||||
|
exit 0 # Nothing changed
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
DATE=$(date '+%Y-%m-%d %H:%M')
|
||||||
|
git add data/dispensa.db
|
||||||
|
git commit -m "📦 Backup database automatico - $DATE"
|
||||||
|
git push
|
||||||
Binary file not shown.
Reference in New Issue
Block a user