in files/gitlab-ctl-commands-ee/lib/geo/replication.rb [84:130]
def execute
check_gitlab_active?
check_service_enabled?
print_warning
confirm_replication
@options[:password] = ask_pass
create_gitlab_backup!
puts '* Stopping PostgreSQL and all GitLab services'.color(:green)
run_command('gitlab-ctl stop')
@pgpass = "#{postgresql_dir_path}/.pgpass"
create_pgpass_file!
check_and_create_replication_slot!
orig_conf = "#{postgresql_dir_path}/data/postgresql.conf"
if File.exist?(orig_conf)
puts '* Backing up postgresql.conf'.color(:green)
run_command("mv #{orig_conf} #{postgresql_dir_path}/")
end
bkp_dir = "#{postgresql_dir_path}/data.#{Time.now.to_i}"
puts "* Moving old data directory to '#{bkp_dir}'".color(:green)
run_command("mv #{postgresql_dir_path}/data #{bkp_dir}")
puts "* Starting base backup as the replicator user (#{@options[:user]})".color(:green)
run_command(pg_basebackup_command,
live: true, timeout: backup_timeout)
puts '* Restoring postgresql.conf'.color(:green)
run_command("mv #{postgresql_dir_path}/postgresql.conf #{postgresql_dir_path}/data/")
write_replication_settings!
puts '* Setting ownership permissions in PostgreSQL data directory'.color(:green)
run_command("chown -R #{postgresql_user}:#{postgresql_group} #{postgresql_dir_path}/data")
puts '* Starting PostgreSQL and all GitLab services'.color(:green)
run_command('gitlab-ctl start')
end