2020-06-23 00:09:42 +05:30
---
2022-07-23 23:45:48 +05:30
stage: Systems
2020-06-23 00:09:42 +05:30
group: Geo
2022-11-25 23:54:43 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
2020-06-23 00:09:42 +05:30
type: howto
---
2021-12-11 22:18:48 +05:30
# Bring a demoted primary site back online **(PREMIUM SELF)**
2019-07-31 22:56:46 +05:30
2021-12-11 22:18:48 +05:30
After a failover, it is possible to fail back to the demoted **primary** site to
2019-07-31 22:56:46 +05:30
restore your original configuration. This process consists of two steps:
2021-12-11 22:18:48 +05:30
1. Making the old **primary** site a **secondary** site.
1. Promoting a **secondary** site to a **primary** site.
2019-07-31 22:56:46 +05:30
2021-02-22 17:27:13 +05:30
WARNING:
2021-12-11 22:18:48 +05:30
If you have any doubts about the consistency of the data on this site, we recommend setting it up from scratch.
2019-07-31 22:56:46 +05:30
2021-12-11 22:18:48 +05:30
## Configure the former **primary** site to be a **secondary** site
2019-07-31 22:56:46 +05:30
2022-07-23 23:45:48 +05:30
Since the former **primary** site is out of sync with the current **primary** site, the first step is to bring the former **primary** site up to date. Note, deletion of data stored on disk like
repositories and uploads is not replayed when bringing the former **primary** site back
2019-07-31 22:56:46 +05:30
into sync, which may result in increased disk usage.
2020-11-24 15:15:51 +05:30
Alternatively, you can [set up a new **secondary** GitLab instance ](../setup/index.md ) to avoid this.
2019-07-31 22:56:46 +05:30
2021-12-11 22:18:48 +05:30
To bring the former **primary** site up to date:
2019-07-31 22:56:46 +05:30
2021-12-11 22:18:48 +05:30
1. SSH into the former **primary** site that has fallen behind.
2023-03-17 16:20:25 +05:30
1. Remove `/etc/gitlab/gitlab-cluster.json` if it exists.
If the site to be re-added as a **secondary** site was promoted with the `gitlab-ctl geo promote` command, then it may contain a `/etc/gitlab/gitlab-cluster.json` file. For example during `gitlab-ctl reconfigure` , you may notice output like:
```plaintext
The 'geo_primary_role' is defined in /etc/gitlab/gitlab-cluster.json as 'true' and overrides the setting in the /etc/gitlab/gitlab.rb
```
If so, then `/etc/gitlab/gitlab-cluster.json` must be deleted from every Sidekiq, PostgreSQL, Gitaly, and Rails node in the site, to make `/etc/gitlab/gitlab.rb` the single source of truth again.
2019-07-31 22:56:46 +05:30
1. Make sure all the services are up:
2020-03-13 15:44:24 +05:30
```shell
2019-09-30 21:07:59 +05:30
sudo gitlab-ctl start
```
2021-02-22 17:27:13 +05:30
NOTE:
2021-12-11 22:18:48 +05:30
If you [disabled the **primary** site permanently ](index.md#step-2-permanently-disable-the-primary-site ),
2022-07-23 23:45:48 +05:30
you need to undo those steps now. For distributions with systemd, such as Debian/Ubuntu/CentOS7+, you must run
`sudo systemctl enable gitlab-runsvdir` . For distributions without systemd, such as CentOS 6, you need to install
2021-12-11 22:18:48 +05:30
the GitLab instance from scratch and set it up as a **secondary** site by
2020-11-24 15:15:51 +05:30
following [Setup instructions ](../setup/index.md ). In this case, you don't need to follow the next step.
2019-09-30 21:07:59 +05:30
2021-02-22 17:27:13 +05:30
NOTE:
2020-07-28 23:09:34 +05:30
If you [changed the DNS records ](index.md#step-4-optional-updating-the-primary-domain-dns-record )
2022-10-11 01:57:18 +05:30
for this site during disaster recovery procedure you may need to
2022-08-27 11:52:29 +05:30
[block all the writes to this site ](planned_failover.md#prevent-updates-to-the-primary-site )
2019-09-30 21:07:59 +05:30
during this procedure.
2019-07-31 22:56:46 +05:30
2021-12-11 22:18:48 +05:30
1. [Set up database replication ](../setup/database.md ). In this case, the **secondary** site
refers to the former **primary** site.
1. If [PgBouncer ](../../postgresql/pgbouncer.md ) was enabled on the **current secondary** site
(when it was a primary site) disable it by editing `/etc/gitlab/gitlab.rb`
2021-01-29 00:20:46 +05:30
and running `sudo gitlab-ctl reconfigure` .
2021-12-11 22:18:48 +05:30
1. You can then set up database replication on the **secondary** site.
2019-07-31 22:56:46 +05:30
2021-12-11 22:18:48 +05:30
If you have lost your original **primary** site, follow the
[setup instructions ](../setup/index.md ) to set up a new **secondary** site.
2019-07-31 22:56:46 +05:30
2021-12-11 22:18:48 +05:30
## Promote the **secondary** site to **primary** site
2019-07-31 22:56:46 +05:30
2021-12-11 22:18:48 +05:30
When the initial replication is complete and the **primary** site and **secondary** site are
2020-04-22 19:07:51 +05:30
closely in sync, you can do a [planned failover ](planned_failover.md ).
2019-07-31 22:56:46 +05:30
2021-12-11 22:18:48 +05:30
## Restore the **secondary** site
2019-07-31 22:56:46 +05:30
2021-12-11 22:18:48 +05:30
If your objective is to have two sites again, you need to bring your **secondary**
site back online as well by repeating the first step
([configure the former **primary** site to be a **secondary** site](#configure-the-former-primary-site-to-be-a-secondary-site))
for the **secondary** site.