amangs commited on
Commit
9edbb7f
·
verified ·
1 Parent(s): 95762da

Exclude wal shm and journal files from bucket sync

Browse files
Files changed (1) hide show
  1. start.sh +12 -1
start.sh CHANGED
@@ -3,7 +3,16 @@ set -e
3
 
4
  OPENCLAW_DIR="/root/.openclaw"
5
  BUCKET_DIR="/data/openclaw"
6
- EXCLUDES=(--exclude="cache/" --exclude="logs/" --exclude="tmp/" --exclude="*.sock" --exclude="*.lock*")
 
 
 
 
 
 
 
 
 
7
 
8
  # 1. Restore on boot
9
  if [ -d "$BUCKET_DIR" ] && [ "$(ls -A "$BUCKET_DIR" 2>/dev/null)" ]; then
@@ -23,12 +32,14 @@ if [ -d "/data" ]; then
23
  while true; do
24
  sleep 30
25
 
 
26
  for db in "$OPENCLAW_DIR"/state/*.sqlite "$OPENCLAW_DIR"/agents/*/agent/*.sqlite; do
27
  if [ -f "$db" ]; then
28
  python3 -c "import sqlite3; c=sqlite3.connect('$db'); c.execute('PRAGMA wal_checkpoint(PASSIVE);'); c.close()" 2>/dev/null || true
29
  fi
30
  done
31
 
 
32
  rsync -a --delete "${EXCLUDES[@]}" "$OPENCLAW_DIR/" "$BUCKET_DIR/" 2>/dev/null || true
33
  done
34
  ) &
 
3
 
4
  OPENCLAW_DIR="/root/.openclaw"
5
  BUCKET_DIR="/data/openclaw"
6
+ EXCLUDES=(
7
+ --exclude="cache/"
8
+ --exclude="logs/"
9
+ --exclude="tmp/"
10
+ --exclude="*.sock"
11
+ --exclude="*.lock*"
12
+ --exclude="*-wal"
13
+ --exclude="*-shm"
14
+ --exclude="*-journal"
15
+ )
16
 
17
  # 1. Restore on boot
18
  if [ -d "$BUCKET_DIR" ] && [ "$(ls -A "$BUCKET_DIR" 2>/dev/null)" ]; then
 
32
  while true; do
33
  sleep 30
34
 
35
+ # Flush SQLite WAL to main db files
36
  for db in "$OPENCLAW_DIR"/state/*.sqlite "$OPENCLAW_DIR"/agents/*/agent/*.sqlite; do
37
  if [ -f "$db" ]; then
38
  python3 -c "import sqlite3; c=sqlite3.connect('$db'); c.execute('PRAGMA wal_checkpoint(PASSIVE);'); c.close()" 2>/dev/null || true
39
  fi
40
  done
41
 
42
+ # Sync state excluding runtime journals/locks
43
  rsync -a --delete "${EXCLUDES[@]}" "$OPENCLAW_DIR/" "$BUCKET_DIR/" 2>/dev/null || true
44
  done
45
  ) &