Commit 3327aedf authored by Alain Takoudjou's avatar Alain Takoudjou Committed by Kirill Smelkov

gitlab-backup/restore: pg_restore need a least --filename argument for output file

pg_restore command now need at least -d/--dbname or -f/--filename argument.

use --if-exits to not drop table if it doesn't exists.

--------
kirr:

* pg_restore started to require `-f` in PostgreSQL 12. From https://www.postgresql.org/docs/release/12.0/ :

      In pg_restore, require specification of -f - to send the dump contents to standard output (Euler Taveira)
      Previously, this happened by default if no destination was specified, but that was deemed to be unfriendly.

* --if-exists suppresses "does not exist" warnings if restored table did
  not exist in the database. From https://www.postgresql.org/docs/current/app-pgrestore.html :

      --if-exists
          Use DROP ... IF EXISTS commands to drop objects in --clean mode.
          This suppresses “does not exist” errors that might otherwise be
          reported. This option is not valid unless --clean is also specified.

/reviewed-by @kirr
/reviewed-on !9
parent 3230197c
......@@ -268,7 +268,7 @@ backup_restore() {
done
# convert database dump to plain-text sql (as gitlab restore expects)
gitlab-rake -e "exec \"pg_restore --clean \\"$db_pgdump\\" >$tmpd/gitlab_backup/db/database.sql \""
gitlab-rake -e "exec \"pg_restore --clean --if-exists -f $tmpd/gitlab_backup/db/database.sql \\"$db_pgdump\\" \""
rm -rf "$db_pgdump"
# tweak gitlab's backup_information.yml so it says db is included in the backup
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment