@@ -6,8 +6,8 @@ pg_back is a dump tool for PostgreSQL. The goal is to dump all or some
66databases with globals at once in the format you want, because a simple call to
77pg_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
1111in the custom format. It also extract database level ACL and configuration that
1212is not dumped by pg_dump older than 11. Finally, it dumps all configuration
1313options 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```
3137go 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 `
3743in the current directory:
3844
3945```
4046docker 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
4751Use 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
4953instance 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
5361files. The path may contain the ` {dbname} ` keyword, that would be replaced by
5462the 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
5866a ` keyword=value ` libpq connection string like ` pg_dump ` and ` pg_dumpall `
5967accept 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
6371options override configuration options.
6472
6573Per-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
6876named after the database. Per database options override global options of the
6977configuration file.
7078
@@ -78,7 +86,7 @@ templates are dumped. To include templates, use `--with-templates` (`-T`), if
7886templates are includes from the configuration file, ` --without-templates ` force
7987exclude 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
8290of database names. If a database is listed on the command line and part of
8391exclusion 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
103111avoiding 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
106114interval is too small.
107115
108116A 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,
110118respecting single and double quoted values. Even if some operation fails, the
111119post 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+
115125Give the path of the v1 configuration file to the ` --convert-legacy-config `
116126command 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
119133The default configuration file can be printed with the ` --print-default-config `
120134command 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
124141Use the Makefile or regular ` go test ` .
0 commit comments