From 2f627aefb526c98140edb15a2adbaedcece0428f Mon Sep 17 00:00:00 2001 From: Alex Steel <130377221+asteel-gsa@users.noreply.github.com> Date: Tue, 4 Jun 2024 08:17:35 -0400 Subject: [PATCH] Formatting change for the 2 backup commands --- cmd/db_to_db.go | 4 ++-- cmd/db_to_s3.go | 4 ++-- internal/pipes/pg_dump.go | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/db_to_db.go b/cmd/db_to_db.go index eb70ea8..56d3bbd 100644 --- a/cmd/db_to_db.go +++ b/cmd/db_to_db.go @@ -80,7 +80,7 @@ func LocalDatabaseSync( } psql_write := pipes.Psql( - pipes.PG_Dump_Table(source_db_creds, schema, table), + pipes.PG_Dump_Table(source_db_creds, schema, table, "--format plain"), dest_db_creds, ) psql_write.Wait() @@ -118,7 +118,7 @@ func CgovDatabaseSync( } psql_write := pipes.Psql( - pipes.PG_Dump_Table(source_db_creds, schema, table), + pipes.PG_Dump_Table(source_db_creds, schema, table, "--format plain"), dest_db_creds, ) psql_write.Wait() diff --git a/cmd/db_to_s3.go b/cmd/db_to_s3.go index ab1ce18..210f068 100644 --- a/cmd/db_to_s3.go +++ b/cmd/db_to_s3.go @@ -77,7 +77,7 @@ func tables_to_local_bucket( // 2. When there are no names in the list (backup all). if slices.Contains(table_names, table) || BACKUP_ALL { mc_pipe := pipes.McWrite( - pipes.PG_Dump_Table(source_creds, schema, table), + pipes.PG_Dump_Table(source_creds, schema, table, "--format c"), up_creds, fmt.Sprintf("%s%s/%s-%s.dump", s3path.Bucket, s3path.Key, schema, table), ) @@ -102,7 +102,7 @@ func tables_to_cgov_bucket( for table, schema := range table_to_schema { if slices.Contains(table_names, table) || BACKUP_ALL { s3_pipe := pipes.S3Write( - pipes.PG_Dump_Table(source_creds, schema, table), + pipes.PG_Dump_Table(source_creds, schema, table, "--format c"), s3_creds, fmt.Sprintf("%s%s/%s-%s.dump", s3path.Bucket, s3path.Key, schema, table), ) diff --git a/internal/pipes/pg_dump.go b/internal/pipes/pg_dump.go index f27ef8f..d80e93c 100644 --- a/internal/pipes/pg_dump.go +++ b/internal/pipes/pg_dump.go @@ -12,14 +12,15 @@ import ( func PG_Dump_Table(creds vcap.Credentials, schema string, - table string) *script.Pipe { + table string, + format string) *script.Pipe { // Compose the command as a slice cmd := []string{ util.PGDUMP_path, "--no-password", "--no-privileges", "--no-owner", - "--format c", + format, // need plain for db_to_db "--table", fmt.Sprintf("%s.%s", schema, table), "--dbname",