4.4 KiB
suzhu kgrag migration steps
This flow is the safer staged migration path:
- export data inside the source
kgragcontainer docker cpthe archive to the source hostscpthe archive to192.168.1.108- extract it under
/home/workspace/kgrag - import Neo4j snapshot, rebuild indexes, update URLs, verify
It avoids directly running cross-host rsync against the live target directory.
Hosts
Source host:
192.168.0.164 root Echo@456
Target host:
192.168.1.108 root zdht123@
Target migration directory:
/home/workspace/suzhu-kgrag_migration
Target kgrag app directory:
/home/workspace/kgrag
Inside the target kgrag container, the mounted script directory is:
/app/suzhu-kgrag_migration
1. Copy export script from target to source
Run on 192.168.1.108:
scp /home/workspace/suzhu-kgrag_migration/00_export_from_source_container.sh \
root@192.168.0.164:/home/workspace/
2. Export data on source host
Run on 192.168.0.164:
bash /home/workspace/00_export_from_source_container.sh
By default it exports from:
container: kgrag
container dir: /app
It packages these items if they exist:
files
kg_output
kg_snapshot.json
fault_wenjian
entity_registry.json
tree_data.json
The archive will be created on the source host under:
/home/workspace/kgrag_export/kgrag_data_YYYYmmddHHMMSS.tar.gz
If the source container name is not kgrag, run:
KGRAG_CONTAINER=your_container_name bash /home/workspace/00_export_from_source_container.sh
3. Copy archive back to target
Run on 192.168.1.108:
mkdir -p /home/workspace/kgrag_import
scp root@192.168.0.164:/home/workspace/kgrag_export/kgrag_data_*.tar.gz \
/home/workspace/kgrag_import/
Check the archive:
ls -lh /home/workspace/kgrag_import/kgrag_data_*.tar.gz
tar -tzf /home/workspace/kgrag_import/kgrag_data_*.tar.gz | sed -n '1,40p'
4. Extract archive into target kgrag directory
Run on 192.168.1.108:
cd /home/workspace/kgrag
tar -xzf /home/workspace/kgrag_import/kgrag_data_*.tar.gz
Check expected files:
ls -ld /home/workspace/kgrag/files \
/home/workspace/kgrag/kg_output \
/home/workspace/kgrag/fault_wenjian 2>/dev/null || true
ls -lh /home/workspace/kgrag/kg_snapshot.json \
/home/workspace/kgrag/entity_registry.json \
/home/workspace/kgrag/tree_data.json 2>/dev/null || true
5. Import Neo4j snapshot
Run on 192.168.1.108:
cd /home/workspace/suzhu-kgrag_migration
bash 02_load_neo4j.sh
This reads:
/home/workspace/kgrag/kg_snapshot.json
and imports it inside the target kgrag container through:
/app/kg_snapshot.json
6. Rebuild Neo4j indexes
Run on 192.168.1.108:
cd /home/workspace/suzhu-kgrag_migration
bash 02b_rebuild_index.sh
7. Update old source URLs in Neo4j
Run on 192.168.1.108:
cd /home/workspace/suzhu-kgrag_migration
bash 03_run_in_container.sh
This executes inside the target container:
/app/suzhu-kgrag_migration/03_update_neo4j_urls.py
It replaces URLs like:
http://192.168.0.164:9085
with:
http://192.168.1.108:9085
8. Verify migration
Run on 192.168.1.108:
cd /home/workspace/suzhu-kgrag_migration
bash 05_run_in_container.sh
This executes inside the target container:
/app/suzhu-kgrag_migration/05_verify_migration.py
Full command sequence
# On 192.168.1.108
scp /home/workspace/suzhu-kgrag_migration/00_export_from_source_container.sh root@192.168.0.164:/home/workspace/
# On 192.168.0.164
bash /home/workspace/00_export_from_source_container.sh
# On 192.168.1.108
mkdir -p /home/workspace/kgrag_import
scp root@192.168.0.164:/home/workspace/kgrag_export/kgrag_data_*.tar.gz /home/workspace/kgrag_import/
cd /home/workspace/kgrag
tar -xzf /home/workspace/kgrag_import/kgrag_data_*.tar.gz
cd /home/workspace/suzhu-kgrag_migration
bash 02_load_neo4j.sh
bash 02b_rebuild_index.sh
bash 03_run_in_container.sh
bash 05_run_in_container.sh
Notes
- Do not run
01_copy_files.shfor this staged flow. That script directly pulls files withrsyncfrom the source host. 02_load_neo4j.sh,02b_rebuild_index.sh, and03_run_in_container.shmodify the target Neo4j data/indexes.- Keep the archive under
/home/workspace/kgrag_importuntil verification passes.