elmerzole commited on
Commit
d3c27ad
·
verified ·
1 Parent(s): 8a1f34a

Update sync_data.sh

Browse files
Files changed (1) hide show
  1. sync_data.sh +5 -5
sync_data.sh CHANGED
@@ -13,16 +13,16 @@ echo "Configuring for HuggingFace Space deployment"
13
  mkdir -p /app/backend/data
14
  mkdir -p /app/db
15
 
16
- # Clone or update repo
17
  if [ ! -d "$TEMP_REPO/.git" ]; then
18
  echo "Cloning repo ${G_NAME}..."
19
  git clone "$REPO_URL" "$TEMP_REPO"
20
  else
21
  echo "Repo already cloned, pulling latest..."
22
- cd "$TEMP_REPO" && git pull && cd -
23
  fi
24
 
25
- # Configure git identity for commits
26
  cd "$TEMP_REPO"
27
  git config user.email "${G_EMAIL:-huggingface-bot@users.noreply.github.com}"
28
  git config user.name "${G_USER:-HuggingFace Bot}"
@@ -30,7 +30,7 @@ cd -
30
 
31
  cd /app/backend
32
 
33
- # If encrypted DB exists in repo → decrypt into the real Open-WebUI DB location
34
  if [ -f "$TEMP_REPO/$ENCRYPTED_DB" ]; then
35
  echo "Found encrypted DB in repo, decrypting..."
36
  gpg --batch --yes --passphrase "$GPG_PASSPHRASE" \
@@ -56,7 +56,7 @@ while true; do
56
  cd "$TEMP_REPO"
57
  git add "$ENCRYPTED_DB"
58
  git commit -m "DB sync: $(date)" || true
59
- git push "$REPO_URL" main || echo "Push failed, will retry next sync..."
60
  cd /app/backend
61
 
62
  echo "[$(date)] Sync done, sleeping 5 mins..."
 
13
  mkdir -p /app/backend/data
14
  mkdir -p /app/db
15
 
16
+ # Clone or init repo
17
  if [ ! -d "$TEMP_REPO/.git" ]; then
18
  echo "Cloning repo ${G_NAME}..."
19
  git clone "$REPO_URL" "$TEMP_REPO"
20
  else
21
  echo "Repo already cloned, pulling latest..."
22
+ cd "$TEMP_REPO" && git fetch --all && git reset --hard origin/main && cd -
23
  fi
24
 
25
+ # Configure git identity
26
  cd "$TEMP_REPO"
27
  git config user.email "${G_EMAIL:-huggingface-bot@users.noreply.github.com}"
28
  git config user.name "${G_USER:-HuggingFace Bot}"
 
30
 
31
  cd /app/backend
32
 
33
+ # If encrypted DB exists in repo → decrypt into working DB
34
  if [ -f "$TEMP_REPO/$ENCRYPTED_DB" ]; then
35
  echo "Found encrypted DB in repo, decrypting..."
36
  gpg --batch --yes --passphrase "$GPG_PASSPHRASE" \
 
56
  cd "$TEMP_REPO"
57
  git add "$ENCRYPTED_DB"
58
  git commit -m "DB sync: $(date)" || true
59
+ git push --force "$REPO_URL" HEAD:main || echo "Force push failed, will retry..."
60
  cd /app/backend
61
 
62
  echo "[$(date)] Sync done, sleeping 5 mins..."