Space Bot commited on
Commit
b8f63d6
·
1 Parent(s): d43cae3

background backup db script every 24h

Browse files
Files changed (1) hide show
  1. backend/start.sh +23 -1
backend/start.sh CHANGED
@@ -59,4 +59,26 @@ if [ -n "$SPACE_ID" ]; then
59
  export WEBUI_URL=${SPACE_HOST}
60
  fi
61
 
62
- WEBUI_SECRET_KEY="$WEBUI_SECRET_KEY" exec uvicorn open_webui.main:app --host "$HOST" --port "$PORT" --forwarded-allow-ips '*'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  export WEBUI_URL=${SPACE_HOST}
60
  fi
61
 
62
+ # 6. Launch the main web server in the background (DO NOT use 'exec' here)
63
+ WEBUI_SECRET_KEY="$WEBUI_SECRET_KEY" uvicorn open_webui.main:app \
64
+ --host "$HOST" --port "$PORT" --forwarded-allow-ips '*' &
65
+ WEBUI_PID=$!
66
+
67
+ # 7. Background job for daily backup
68
+ (
69
+ # Optional: wait a few minutes before the first backup, so the DB is stable
70
+ sleep 300
71
+
72
+ while true; do
73
+ echo "==============================================="
74
+ echo "Daily backup job: encrypting and pushing the DB"
75
+ echo "==============================================="
76
+ # Calls your db_crypt.sh function
77
+ bash "$SCRIPT_DIR/scripts/db_crypt.sh" encrypt_database
78
+ # Sleep for 24 hours
79
+ sleep 86400
80
+ done
81
+ ) &
82
+
83
+ # 8. Wait on the main web server (keep container alive)
84
+ wait $WEBUI_PID