diff --git a/deployment/development/backup_and_restore_workflow.md b/deployment/development/backup_and_restore_workflow.md index d082f6b4..6d7ea292 100644 --- a/deployment/development/backup_and_restore_workflow.md +++ b/deployment/development/backup_and_restore_workflow.md @@ -99,6 +99,7 @@ docker-compose up -d mongodb postgres neo4j ./init.sh backup_postgres ``` This creates `opengin.tar.gz` in your PostgreSQL backup directory. + Note: PostgreSQL backups are created using `pg_dump --clean --if-exists`. Restoring from these backups will drop and recreate objects contained in the dump. Treat restores as destructive operations and run them only against a dedicated development database; do not rely on them being fully idempotent if the target database contains additional objects. 3. **Backup Neo4j:** ```bash diff --git a/deployment/development/init.sh b/deployment/development/init.sh index ca070c26..ef9776b7 100755 --- a/deployment/development/init.sh +++ b/deployment/development/init.sh @@ -362,7 +362,7 @@ backup_postgres() { # Run pg_dump and capture output log "INFO" "Running pg_dump command..." - pg_dump_output=$(docker exec postgres pg_dump -U postgres -h localhost -d ${POSTGRES_DATABASE} -f "/var/lib/postgresql/backup/${backup_file}.sql" 2>&1) + pg_dump_output=$(docker exec postgres pg_dump -U "$POSTGRES_USER" -h localhost -d "$POSTGRES_DATABASE" --clean --if-exists -f "/var/lib/postgresql/backup/${backup_file}.sql" 2>&1) pg_dump_exit_code=$? log "INFO" "Pg_dump output: $pg_dump_output"