Skip to content

Support overriding ActiveRecord settings per database

What does this MR do and why?

The GitLab database backup is using database.yml settings for connecting to the database. We do support overriding these settings for backup purposes.

The current implementation of these overrides works with multiple databases. But it does not allow to have different overrides for different databases. For example, it assumes that main and ci database are on the same database server.

This MR will allow administrators to override settings per database. For example, if you want to override the host name, you can now use GITLAB_BACKUP_CI_PGHOST.

Related to #423536 (closed)

How to set up and validate locally

Using GDK:

  1. Forward TCP/IP port 15432 to the PostgreSQL socket. For example using socat: socat TCP-LISTEN:15432,reuseaddr,fork UNIX-CLIENT:/Users/rutger/gitlab-development-kit/postgresql/.s.PGSQL.5432
  2. Run GITLAB_BACKUP_CI_PGHOST=localhost GITLAB_BACKUP_CI_PGPORT=25432 bundle exec rake gitlab:backup:db:create. This will fail but the error message should mention port 25432 so we know it is the wrong port.
  3. Run GITLAB_BACKUP_CI_PGHOST=localhost GITLAB_BACKUP_CI_PGPORT=15432 bundle exec rake gitlab:backup:db:create. This results in succesful backup. (ls -lah ~/gitlab-development-kit/gitlab/tmp/backups/db/)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Rutger Wessels

Merge request reports