Skip to content

Commit

Permalink
Address #50: complain about archive_mode and archive_command. Current…
Browse files Browse the repository at this point in the history
…ly this is printed as warning. Will consider panic in future
  • Loading branch information
x4m committed Jan 17, 2018
1 parent 5fc7f48 commit d611294
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,30 @@ func Connect() (*pgx.Conn, error) {
return nil, errors.Wrap(err, "Connect: postgres connection failed")
}

var archive_mode string

err = conn.QueryRow("show archive_mode").Scan(&archive_mode)

if err != nil {
return nil, errors.Wrap(err, "Connect: postgres archive_mode test failed")
}

if archive_mode != "on" && archive_mode != "always" {
log.Println("WARNING! It seems your archive_mode is not enabled. This will cause inconsistent backup. Please consider configuring WAL archiving.")
} else {
var archive_command string

err = conn.QueryRow("show archive_command").Scan(&archive_command)

if err != nil {
return nil, errors.Wrap(err, "Connect: postgres archive_mode test failed")
}

if (len(archive_command) == 0 || archive_command == "(disabled)") {
log.Println("WARNING! It seems your archive_command is not configured. This will cause inconsistent backup. Please consider configuring WAL archiving.")
}
}

return conn, nil
}

Expand Down

0 comments on commit d611294

Please sign in to comment.