A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/orgrim/pg_back/commit/df166fafae96e847c88a8917e4dbf42a4fb4ca6f below:

Add the --dump-only option to only dump databases · orgrim/pg_back@df166fa · GitHub

@@ -153,7 +153,7 @@ func run() (retVal error) {

153 153

var cliOptions options

154 154 155 155

if cliOpts.NoConfigFile {

156 -

l.Infoln("*** Skipping reading config file")

156 +

l.Infoln("Skipping reading config file")

157 157

cliOptions = defaultOptions()

158 158

} else {

159 159

// Load configuration file and allow the default configuration

@@ -277,38 +277,40 @@ func run() (retVal error) {

277 277

}

278 278

defer db.Close()

279 279 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 +

}

283 284 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 +

}

295 296 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 +

)

301 302 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 +

}

307 309

}

308 -

}

309 310 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 +

}

312 314

}

313 315 314 316

databases, err := listDatabases(db, opts.WithTemplates, opts.ExcludeDbs, opts.Dbnames)

@@ -367,6 +369,15 @@ func run() (retVal error) {

367 369 368 370

canDumpACL := true

369 371

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 + 370 381

// collect the result of the jobs

371 382

for j := 0; j < numJobs; j++ {

372 383

var b, c string

@@ -407,6 +418,7 @@ func run() (retVal error) {

407 418

l.Verboseln("dumping configuration of", dbname)

408 419

c, err = dumpDBConfig(db, dbname)

409 420

if err != nil {

421 +

var verr *pgVersionError

410 422

if !errors.As(err, &verr) {

411 423

l.Errorln(err)

412 424

exitCode = 1


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4