diff --git a/install.sh b/install.sh index 502b64c..bde89fe 100755 --- a/install.sh +++ b/install.sh @@ -68,6 +68,15 @@ if [ "${1:-}" = "-update" ]; then cd "$INSTALL_DIR" fi + # Backup the database before making any changes. + if [ -f "$INSTALL_DIR/expenses.db" ]; then + BACKUP_DIR="$INSTALL_DIR/backups" + sudo_if mkdir -p "$BACKUP_DIR" + BACKUP_FILE="$BACKUP_DIR/expenses-$(date +%Y%m%d-%H%M%S).db" + sudo_if cp "$INSTALL_DIR/expenses.db" "$BACKUP_FILE" + info "Database backed up to $BACKUP_FILE" + fi + # Copy updated templates, static assets, and config files. info "Updating templates and static assets..." sudo_if rsync -a --delete templates/ "$INSTALL_DIR/templates/" 2>/dev/null || true