Skip to content

Commit 67722a1

Browse files
authored
Improve README.md (#44)
* README.md review * README.md: conversion example Contribution by Christophe Courtois
1 parent e8a9c0d commit 67722a1

File tree

1 file changed

+34
-17
lines changed

1 file changed

+34
-17
lines changed

README.md

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ pg_back is a dump tool for PostgreSQL. The goal is to dump all or some
66
databases with globals at once in the format you want, because a simple call to
77
pg_dumpall only dumps databases in the plain SQL format.
88

9-
Behind the scene, pg_back uses pg_dumpall to dump roles and tablespaces
10-
definitions, pg_dump to dump all or each selected database to a separate file
9+
Behind the scene, pg_back uses `pg_dumpall` to dump roles and tablespaces
10+
definitions, `pg_dump` to dump all or each selected database to a separate file
1111
in the custom format. It also extract database level ACL and configuration that
1212
is not dumped by pg_dump older than 11. Finally, it dumps all configuration
1313
options of the PostgreSQL instance.
@@ -27,29 +27,37 @@ options of the PostgreSQL instance.
2727

2828
## Install
2929

30+
A compiled binary is available from the [Github repository](https://github.com/orgrim/pg_back/releases).
31+
32+
The binary only needs `pg_dumpall` and `pg_dump`.
33+
34+
## Install from source
35+
3036
```
3137
go get -u github.com/orgrim/pg_back
3238
```
3339

34-
Use `make` to build and install from source.
40+
Use `make` to build and install from source (you need go 1.16 or above).
3541

36-
As an alternative, the following *docker* command downloads, compiles and put `pg_back`
42+
As an alternative, the following *docker* command downloads, compiles and puts `pg_back`
3743
in the current directory:
3844

3945
```
4046
docker run --rm -v "$PWD":/go/bin golang:1.16 go get github.com/orgrim/pg_back
4147
```
4248

43-
The binary only needs `pg_dumpall` and `pg_dump`.
44-
4549
## Usage
4650

4751
Use the `--help` or `-?` to print the list of available options. To dump all
48-
database, you only need to give the proper connection options to the PostgreSQL
52+
databases, you only need to give the proper connection options to the PostgreSQL
4953
instance and the path to a writable directory to store the dump files.
5054

51-
The defaut output directory `/var/backups/postgresql` may not exists or have
52-
the proper ownership for you user, use `-b` to give the path where to store the
55+
If default and command line options are not enough, a configuration file
56+
may be provided with `-c <configfilename>`.
57+
(Note: see below to convert configuration files from version 1.)
58+
59+
If the default output directory `/var/backups/postgresql` does not exist or has
60+
improper ownership for your user, use `-b` to give the path where to store the
5361
files. The path may contain the `{dbname}` keyword, that would be replaced by
5462
the name of the database being dumped, this permits to dump.
5563

@@ -58,13 +66,13 @@ need less known connection options such as `sslcert` and `sslkey`, you can give
5866
a `keyword=value` libpq connection string like `pg_dump` and `pg_dumpall`
5967
accept with their `-d` option.
6068

61-
The others command line options let you tweak what is dumped, purged, and how
62-
it is done. These options can be put in a configuration file. The command lien
69+
The other command line options let you tweak what is dumped, purged, and how
70+
it is done. These options can be put in a configuration file. The command line
6371
options override configuration options.
6472

6573
Per-database configuration can only be done with a configuration file. The
66-
configuration file uses the ini format, global options are in a unspecified
67-
section at the top of the file and database specific options are in a section
74+
configuration file uses the `ini` format, global options are in a unspecified
75+
section at the top of the file, and database specific options are in a section
6876
named after the database. Per database options override global options of the
6977
configuration file.
7078

@@ -78,7 +86,7 @@ templates are dumped. To include templates, use `--with-templates` (`-T`), if
7886
templates are includes from the configuration file, `--without-templates` force
7987
exclude them.
8088

81-
Databases can be excluded with --exclude-dbs (-D), it is a comma separated list
89+
Databases can be excluded with `--exclude-dbs` (`-D`), which is a comma separated list
8290
of database names. If a database is listed on the command line and part of
8391
exclusion list, exclusion wins.
8492

@@ -102,23 +110,32 @@ A number of dump files to keep when purging can also be specified with
102110
`--purge-min-keep` (`-K`) with the special value `all` to keep everything, thus
103111
avoiding file removal completly. When both `--purge-older-than` and
104112
`--purge-min-keep` are used, the minimum number of dumps to keep is enforced
105-
before old dumps are removed. This avoid remove all dumps when the time
113+
before old dumps are removed. This avoids removing all dumps when the time
106114
interval is too small.
107115

108116
A command can be run before taking dumps with `--pre-backup-hook`, and after
109-
with `--post-backup-hook`. The command are executed directly, not by a shell,
117+
with `--post-backup-hook`. The commands are executed directly, not by a shell,
110118
respecting single and double quoted values. Even if some operation fails, the
111119
post backup hook is executed when present.
112120

113121
## Managing the configuration file
114122

123+
The previous v1 configuration files are not compatible with pg_back v2.
124+
115125
Give the path of the v1 configuration file to the `--convert-legacy-config`
116126
command line option, and pg_back will try its best to convert it to the v2
117-
format.
127+
format. Redirect the output to the new configuration file:
128+
129+
```
130+
pg_back --convert-legacy-config pg_back1.conf > pg_back2.conf
131+
```
118132

119133
The default configuration file can be printed with the `--print-default-config`
120134
command line option.
121135

136+
On some environments (especially Debian), you may have to add `host = /var/run/postgresql`
137+
to override the default `/tmp` host.
138+
122139
## Testing
123140

124141
Use the Makefile or regular `go test`.

0 commit comments

Comments
 (0)