Pre-Migration Directory Preparation
First, set up temporary backup directories for the migration. On the source FastGPT Docker container (Environment A), create a backup directory inside the container:
docker exec -it fastgpt sh
mkdir -p /data/backupExported MongoDB files will auto-sync to the host’s fastgpt/data/backup directory via configured volume mounts. If auto-sync fails, use docker cp to manually transfer files. On the source host, create a matching backup subdirectory in the FastGPT mongo folder:
mkdir -p /fastgpt/data/backupCreate a dedicated backup directory on the target host (Environment B) to store the transferred archive:
mkdir -p /fastgpt/mongobackupExport Source MongoDB Data
Export the fastgpt database from the source MongoDB instance. You can run this command directly on the source host without entering the container:
docker exec -it mongo bash -c "mongodump --db fastgpt -u 'username' -p 'password' --authenticationDatabase admin --out /data/backup"Alternatively, enter the container and execute the export workflow step-by-step:
docker exec -it fastgpt shmkdir -p /data/backupmongodump --host 127.0.0.1:27017 --db fastgpt -u "username" -p "password" --authenticationDatabase admin --out /data/backup
If exported files do not auto-sync to the source host, copy them manually:
docker cp mongo:/data/backup [local-fastgpt-dir]:/fastgpt/data/backupValidate and Transfer Backup Archive
Compress the backup directory to verify integrity before transfer. Navigate to the source host’s FastGPT mongo data directory:
cd /usr/fastgpt/mongo/dataCreate a timestamped compressed archive:
tar -czvf ../fastgpt-mongo-backup-$(date +%Y-%m-%d).tar.gz ./Extract the archive on a staging environment (Environment C) to confirm valid .bson files:
tar -xvzf fastgptbackup-2024-05-03.tar.gz -C user/fastgpt/mongobackup/dataVerify the extracted file count matches the source to prevent incomplete data imports. Transfer the verified archive to the target host:
scp -i /Users/path/[your-pem-file] root@[old-server-ip]:/usr/fastgpt/mongo/fastgptbackup-2024-05-03.tar.gz root@[new-server-ip]:/Downloads/fastgpt2Upload the archive to the target host’s designated backup directory (do not use fastgpt/data/ to avoid import errors):
scp -rfv [local-path]/Downloads/fastgpt/fastgptbackup-2024-05-03.tar.gz root@[new-server-ip]:/Downloads/fastgpt/backupSource: FastGPT official source
Applicability and version scope
Use this page for the documented Deployment and upgrades scenario. Confirm the FastGPT, dependency, API, and deployment versions in the official source before applying a change.
Safety guardrails
Use [REDACTED_CREDENTIAL] for credentials and private data. Confirm the documented environment and version before review.
Rollback guidance
Restore the prior technical-content authority snapshot. Restore saved configuration and data snapshots, then repeat the smallest verification scenario.