@@ -153,7 +153,7 @@ func run() (retVal error) {
153153 var cliOptions options
154154
155155 if cliOpts .NoConfigFile {
156- l .Infoln ("*** Skipping reading config file" )
156+ l .Infoln ("Skipping reading config file" )
157157 cliOptions = defaultOptions ()
158158 } else {
159159 // Load configuration file and allow the default configuration
@@ -277,38 +277,40 @@ func run() (retVal error) {
277277 }
278278 defer db .Close ()
279279
280- if ! db .superuser {
281- l .Infoln ("connection user is not superuser, some information will not be dumped" )
282- }
280+ if ! opts .DumpOnly {
281+ if ! db .superuser {
282+ l .Infoln ("connection user is not superuser, some information will not be dumped" )
283+ }
283284
284- // Then we can implicitely avoid dumping role password when using a
285- // regular user
286- dumpRolePasswords := opts .WithRolePasswords && db .superuser
287- if dumpRolePasswords {
288- l .Infoln ("dumping globals" )
289- } else {
290- l .Infoln ("dumping globals without role passwords" )
291- }
292- if err := dumpGlobals (opts .Directory , opts .TimeFormat , dumpRolePasswords , conninfo , producedFiles ); err != nil {
293- return fmt .Errorf ("pg_dumpall of globals failed: %w" , err )
294- }
285+ // Then we can implicitely avoid dumping role password when using a
286+ // regular user
287+ dumpRolePasswords := opts .WithRolePasswords && db .superuser
288+ if dumpRolePasswords {
289+ l .Infoln ("dumping globals" )
290+ } else {
291+ l .Infoln ("dumping globals without role passwords" )
292+ }
293+ if err := dumpGlobals (opts .Directory , opts .TimeFormat , dumpRolePasswords , conninfo , producedFiles ); err != nil {
294+ return fmt .Errorf ("pg_dumpall of globals failed: %w" , err )
295+ }
295296
296- l .Infoln ("dumping instance configuration" )
297- var (
298- verr * pgVersionError
299- perr * pgPrivError
300- )
297+ l .Infoln ("dumping instance configuration" )
298+ var (
299+ verr * pgVersionError
300+ perr * pgPrivError
301+ )
301302
302- if err := dumpSettings (opts .Directory , opts .TimeFormat , db , producedFiles ); err != nil {
303- if errors .As (err , & verr ) || errors .As (err , & perr ) {
304- l .Warnln (err )
305- } else {
306- return fmt .Errorf ("could not dump configuration parameters: %w" , err )
303+ if err := dumpSettings (opts .Directory , opts .TimeFormat , db , producedFiles ); err != nil {
304+ if errors .As (err , & verr ) || errors .As (err , & perr ) {
305+ l .Warnln (err )
306+ } else {
307+ return fmt .Errorf ("could not dump configuration parameters: %w" , err )
308+ }
307309 }
308- }
309310
310- if err := dumpConfigFiles (opts .Directory , opts .TimeFormat , db , producedFiles ); err != nil {
311- return fmt .Errorf ("could not dump configuration files: %w" , err )
311+ if err := dumpConfigFiles (opts .Directory , opts .TimeFormat , db , producedFiles ); err != nil {
312+ return fmt .Errorf ("could not dump configuration files: %w" , err )
313+ }
312314 }
313315
314316 databases , err := listDatabases (db , opts .WithTemplates , opts .ExcludeDbs , opts .Dbnames )
@@ -367,6 +369,15 @@ func run() (retVal error) {
367369
368370 canDumpACL := true
369371 canDumpConfig := true
372+
373+ // When asked to only dump database, exclude ACL and config even if
374+ // this can lead of missing info on restore when pg_dump is older than
375+ // 11
376+ if opts .DumpOnly {
377+ canDumpACL = false
378+ canDumpConfig = false
379+ }
380+
370381 // collect the result of the jobs
371382 for j := 0 ; j < numJobs ; j ++ {
372383 var b , c string
@@ -407,6 +418,7 @@ func run() (retVal error) {
407418 l .Verboseln ("dumping configuration of" , dbname )
408419 c , err = dumpDBConfig (db , dbname )
409420 if err != nil {
421+ var verr * pgVersionError
410422 if ! errors .As (err , & verr ) {
411423 l .Errorln (err )
412424 exitCode = 1
0 commit comments