From 2b520ab75effaccf3b9e729f8678d8916dbe9f79 Mon Sep 17 00:00:00 2001 From: "Kavinda S. Rajapaksha" <125864556+KavindaRajapaksha@users.noreply.github.com> Date: Fri, 13 Mar 2026 18:53:36 +0530 Subject: [PATCH 1/2] add clean postgres dump for safer restores --- deployment/development/backup_and_restore_workflow.md | 1 + deployment/development/init.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/deployment/development/backup_and_restore_workflow.md b/deployment/development/backup_and_restore_workflow.md index d082f6b4..e03e44da 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 with clean drops (`pg_dump --clean --if-exists`), so running restore multiple times is safe and idempotent. 3. **Backup Neo4j:** ```bash diff --git a/deployment/development/init.sh b/deployment/development/init.sh index ca070c26..2e88b2a9 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 -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" From e6936d031aa160529ebb0870c8f83ddbad804005 Mon Sep 17 00:00:00 2001 From: "Kavinda S. Rajapaksha" <125864556+KavindaRajapaksha@users.noreply.github.com> Date: Mon, 16 Mar 2026 13:55:16 +0530 Subject: [PATCH 2/2] use {Postgres_user} instead of hardcode user as postgres --- deployment/development/backup_and_restore_workflow.md | 2 +- deployment/development/init.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/development/backup_and_restore_workflow.md b/deployment/development/backup_and_restore_workflow.md index e03e44da..6d7ea292 100644 --- a/deployment/development/backup_and_restore_workflow.md +++ b/deployment/development/backup_and_restore_workflow.md @@ -99,7 +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 with clean drops (`pg_dump --clean --if-exists`), so running restore multiple times is safe and idempotent. + 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 2e88b2a9..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} --clean --if-exists -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"