Browse Source

Add separate configuration settings for pg_dump and pg_dumpall

Emmanuel Bouthenot 1 year ago
parent
commit
c7e019ff51
3 changed files with 27 additions and 6 deletions
  1. 4 0
      Changelog.md
  2. 7 1
      Documentation.md
  3. 16 5
      autopostgresqlbackup

+ 4 - 0
Changelog.md

@@ -1,5 +1,9 @@
 # Changelog
 
+## Version 2.1
+
+Variable `OPT` (used with pg_dump) is renamed to `PGDUMP_OPTS` and a new variable `PGDUMPALL_OPTS` is available (used for dump globals with pg_dumpall) (Closes: [#12](https://github.com/k0lter/autopostgresqlbackup/issues/12))
+
 ## Version 2.0
 
 * Huge code cleanup and refactoring (Closes: [#2](https://github.com/k0lter/autopostgresqlbackup/issues/2))

+ 7 - 1
Documentation.md

@@ -128,12 +128,18 @@ COMP="zstd"
 COMP_OPTS="-f -c"
 ```
 
-### `OPT`
+### `PGDUMP_OPTS`
 
 Options string for use with pg_dump (see [pg_dump](https://www.postgresql.org/docs/current/app-pgdump.html) manual page).
 
 **default**: `""` (empty)
 
+### `PGDUMPALL_OPTS`
+
+Options string for use with pg_dumpall (see [pg_dumpall](https://www.postgresql.org/docs/current/app-pg-dumpall.html) manual page).
+
+**default**: `""` (empty)
+
 ### `EXT`
 
 Backup files extension

+ 16 - 5
autopostgresqlbackup

@@ -104,7 +104,10 @@ COMP="gzip"
 COMP_OPTS=
 
 # Options string for use with pg_dump (see pg_dump manual page).
-OPT=
+PGDUMP_OPTS=
+
+# Options string for use with pg_dumpall (see pg_dumpall manual page).
+PGDUMPALL_OPTS=
 
 # Backup files extension
 EXT="sql"
@@ -171,10 +174,17 @@ DEBUG="no"
 GPG_HOMEDIR=
 
 # pg_dump options
-if [ -n "${OPT}" ]; then
-    IFS=" " read -r -a PG_OPTIONS <<< "${OPT}"
+if [ -n "${PGDUMP_OPTS}" ]; then
+    IFS=" " read -r -a PGDUMP_ARGS <<< "${PGDUMP_OPTS}"
+else
+    PGDUMP_ARGS=()
+fi
+
+# pg_dumpall options
+if [ -n "${PGDUMPALL_OPTS}" ]; then
+    IFS=" " read -r -a PGDUMPALL_ARGS <<< "${PGDUMPALL_OPTS}"
 else
-    PG_OPTIONS=()
+    PGDUMPALL_ARGS=()
 fi
 
 # Create required directories
@@ -329,14 +339,15 @@ dbdump () {
     local db_name cmd_prog cmd_args pg_args
 
     db_name="${1}"
-    pg_args="${PG_OPTIONS[*]}"
 
     if [ "${db_name}" = "${GLOBALS_OBJECTS}" ]; then
         cmd_prog="pg_dumpall"
         cmd_args=(--globals-only)
+        pg_args="${PGDUMPALL_ARGS[*]}"
     else
         cmd_prog="pg_dump"
         cmd_args=("${db_name}")
+        pg_args="${PGDUMP_ARGS[*]}"
         if [ "${CREATE_DATABASE}" = "yes" ]; then
             pg_args+=(--create)
         fi