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:
dadaloop82
2026-03-10 12:38:20 +00:00
parent c6c000bbc2
commit 24dd88b5cf
3 changed files with 21 additions and 2 deletions
Executable
+18
View File
@@ -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