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/350a3d78d2ecf0a1a59814c11f25e59517bca3ac below:

pg_dump support compression natively with · orgrim/pg_back@350a3d7 · GitHub

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

397 397

// Write ACL and configuration to an SQL file

398 398

if len(b) > 0 || len(c) > 0 {

399 399 400 -

aclpath := formatDumpPath(d.Directory, d.TimeFormat, "createdb.sql", dbname, d.When)

400 +

aclpath := formatDumpPath(d.Directory, d.TimeFormat, "createdb.sql", dbname, d.When, 0)

401 401

if err := os.MkdirAll(filepath.Dir(aclpath), 0755); err != nil {

402 402

l.Errorln(err)

403 403

exitCode = 1

@@ -530,7 +530,7 @@ func (d *dump) dump(fc chan<- sumFileJob) error {

530 530

// dump to prevent stacking pg_back processes if pg_dump last

531 531

// longer than a schedule of pg_back. If the lock cannot be

532 532

// acquired, skip the dump and exit with an error.

533 -

lock := formatDumpPath(d.Directory, d.TimeFormat, "lock", dbname, time.Time{})

533 +

lock := formatDumpPath(d.Directory, d.TimeFormat, "lock", dbname, time.Time{}, 0)

534 534

flock, locked, err := lockPath(lock)

535 535

if err != nil {

536 536

return fmt.Errorf("unable to lock %s: %s", lock, err)

@@ -558,7 +558,7 @@ func (d *dump) dump(fc chan<- sumFileJob) error {

558 558

fileEnd = "d"

559 559

}

560 560 561 -

file := formatDumpPath(d.Directory, d.TimeFormat, fileEnd, dbname, d.When)

561 +

file := formatDumpPath(d.Directory, d.TimeFormat, fileEnd, dbname, d.When, d.Options.CompressLevel)

562 562

formatOpt := fmt.Sprintf("-F%c", d.Options.Format)

563 563 564 564

command := execPath("pg_dump")

@@ -597,9 +597,9 @@ func (d *dump) dump(fc chan<- sumFileJob) error {

597 597

}

598 598

}

599 599 600 -

// Add compression level option only if not dumping in the plain format

600 +

// Add compression level option only if not dumping in the tar format

601 601

if d.Options.CompressLevel >= 0 {

602 -

if d.Options.Format != 'p' && d.Options.Format != 't' {

602 +

if d.Options.Format != 't' {

603 603

args = append(args, "-Z", fmt.Sprintf("%d", d.Options.CompressLevel))

604 604

} else {

605 605

l.Warnln("compression level is not supported by the target format")

@@ -728,7 +728,7 @@ func cleanDBName(dbname string) string {

728 728

return dbname

729 729

}

730 730 731 -

func formatDumpPath(dir string, timeFormat string, suffix string, dbname string, when time.Time) string {

731 +

func formatDumpPath(dir string, timeFormat string, suffix string, dbname string, when time.Time, compressLevel int) string {

732 732

var f, s, d string

733 733 734 734

// Avoid attacks on the database name

@@ -754,6 +754,10 @@ func formatDumpPath(dir string, timeFormat string, suffix string, dbname string,

754 754

f = fmt.Sprintf("%s_%s.%s", dbname, when.Format(timeFormat), s)

755 755

}

756 756 757 +

if suffix == "sql" && compressLevel > 0 {

758 +

f = f + ".gz"

759 +

}

760 + 757 761

return filepath.Join(d, f)

758 762

}

759 763

@@ -808,7 +812,7 @@ func dumpGlobals(dir string, timeFormat string, conninfo *ConnInfo, fc chan<- su

808 812

args = append(args, "-d", conninfo.String())

809 813

}

810 814 811 -

file := formatDumpPath(dir, timeFormat, "sql", "pg_globals", time.Now())

815 +

file := formatDumpPath(dir, timeFormat, "sql", "pg_globals", time.Now(), 0)

812 816

args = append(args, "-f", file)

813 817 814 818

if err := os.MkdirAll(filepath.Dir(file), 0755); err != nil {

@@ -846,7 +850,7 @@ func dumpGlobals(dir string, timeFormat string, conninfo *ConnInfo, fc chan<- su

846 850 847 851

func dumpSettings(dir string, timeFormat string, db *pg, fc chan<- sumFileJob) error {

848 852 849 -

file := formatDumpPath(dir, timeFormat, "out", "pg_settings", time.Now())

853 +

file := formatDumpPath(dir, timeFormat, "out", "pg_settings", time.Now(), 0)

850 854 851 855

if err := os.MkdirAll(filepath.Dir(file), 0755); err != nil {

852 856

return err

@@ -876,7 +880,7 @@ func dumpSettings(dir string, timeFormat string, db *pg, fc chan<- sumFileJob) e

876 880 877 881

func dumpConfigFiles(dir string, timeFormat string, db *pg, fc chan<- sumFileJob) error {

878 882

for _, param := range []string{"hba_file", "ident_file"} {

879 -

file := formatDumpPath(dir, timeFormat, "out", param, time.Now())

883 +

file := formatDumpPath(dir, timeFormat, "out", param, time.Now(), 0)

880 884 881 885

if err := os.MkdirAll(filepath.Dir(file), 0755); err != nil {

882 886

return err


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