diff --git a/backup/data.go b/backup/data.go index 7f92cdcde..dd7ca97ea 100644 --- a/backup/data.go +++ b/backup/data.go @@ -59,6 +59,7 @@ func CopyTableOut(connectionPool *dbconn.DBConn, table Table, destinationToWrite checkPipeExistsCommand := "" customPipeThroughCommand := utils.GetPipeThroughProgram().OutputCommand sendToDestinationCommand := ">" + copyCommand := "" if MustGetFlagBool(options.SINGLE_DATA_FILE) { /* * The segment TOC files are always written to the segment data directory for @@ -70,9 +71,13 @@ func CopyTableOut(connectionPool *dbconn.DBConn, table Table, destinationToWrite customPipeThroughCommand = "cat -" } else if MustGetFlagString(options.PLUGIN_CONFIG) != "" { sendToDestinationCommand = fmt.Sprintf("| %s backup_data %s", pluginConfig.ExecutablePath, pluginConfig.ConfigPath) + } else if customPipeThroughCommand == "cat -" { + copyCommand = fmt.Sprintf("'%s'", destinationToWrite) } - copyCommand := fmt.Sprintf("PROGRAM '%s%s %s %s'", checkPipeExistsCommand, customPipeThroughCommand, sendToDestinationCommand, destinationToWrite) + if copyCommand == "" { + copyCommand = fmt.Sprintf("PROGRAM '%s%s %s %s'", checkPipeExistsCommand, customPipeThroughCommand, sendToDestinationCommand, destinationToWrite) + } query := fmt.Sprintf("COPY %s TO %s WITH CSV DELIMITER '%s' ON SEGMENT IGNORE EXTERNAL PARTITIONS;", table.FQN(), copyCommand, tableDelim) gplog.Verbose("Worker %d: %s", connNum, query) diff --git a/backup/data_test.go b/backup/data_test.go index ffb0b31fa..736362201 100644 --- a/backup/data_test.go +++ b/backup/data_test.go @@ -121,7 +121,7 @@ var _ = Describe("backup/data tests", func() { }) It("will back up a table to its own file without compression", func() { utils.SetPipeThroughProgram(utils.PipeThroughProgram{Name: "cat", OutputCommand: "cat -", InputCommand: "cat -", Extension: ""}) - execStr := regexp.QuoteMeta("COPY public.foo TO PROGRAM 'cat - > /backups/20170101/20170101010101/gpbackup__20170101010101_3456' WITH CSV DELIMITER ',' ON SEGMENT IGNORE EXTERNAL PARTITIONS;") + execStr := regexp.QuoteMeta("COPY public.foo TO '/backups/20170101/20170101010101/gpbackup__20170101010101_3456' WITH CSV DELIMITER ',' ON SEGMENT IGNORE EXTERNAL PARTITIONS;") mock.ExpectExec(execStr).WillReturnResult(sqlmock.NewResult(10, 0)) filename := "/backups/20170101/20170101010101/gpbackup__20170101010101_3456"