# README
pg-commands
install
go get -t github.com/habx/pg-commands
Example
Code
dump, _ := pg.NewDump(&pg.Postgres{
Host: "localhost",
Port: 5432,
DB: "dev_example",
Username: "example",
Password: "example",
})
dumpExec := dump.Exec(pg.ExecOptions{StreamPrint: false})
if dumpExec.Error != nil {
fmt.Println(dumpExec.Error.Err)
fmt.Println(dumpExec.Output)
} else {
fmt.Println("Dump success")
fmt.Println(dumpExec.Output)
}
restore, _ := pg.NewRestore(&pg.Postgres{
Host: "localhost",
Port: 5432,
DB: "dev_example",
Username: "example",
Password: "example",
})
restoreExec := restore.Exec(dumpExec.File, pg.ExecOptions{StreamPrint: false})
if restoreExec.Error != nil {
fmt.Println(restoreExec.Error.Err)
fmt.Println(restoreExec.Output)
} else {
fmt.Println("Restore success")
fmt.Println(restoreExec.Output)
}
Lab
$ cd examples
$ docker-compose up -d
$ cd ..
$ POSTGRES_USER=example POSTGRES_PASSWORD=example POSTGRES_DB=postgres go run tests/fixtures/scripts/init-database/init-database.go
$ go run main.go
Dump success
Restore success
# Functions
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
PGDumpCmd is the path to the `pg_dump` executable.
PGRestoreCmd is the path to the `pg_restore` executable.
# Structs
Dump is an `Exporter` interface that backs up a Postgres database via the `pg_dump` command.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author