Commit 6d9f1e0b authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'patch-2' into 'master'

Document that only unicorn and sidekiq should be stopped.

And the rest of GitLab should remain running.
Also clarified the rest of the GitLab Omnibus restore procedure.

See merge request !3839
parents d3aed10d e157e971
...@@ -295,37 +295,55 @@ Deleting tmp directories...[DONE] ...@@ -295,37 +295,55 @@ Deleting tmp directories...[DONE]
### Omnibus installations ### Omnibus installations
We will assume that you have installed GitLab from an omnibus package and run We will assume that you have installed GitLab from an Omnibus package and run
`sudo gitlab-ctl reconfigure` at least once. `sudo gitlab-ctl reconfigure` at least once.
First make sure your backup tar file is in `/var/opt/gitlab/backups` (or wherever `gitlab_rails['backup_path']` points to). First make sure your backup tar file is in the directory specified by
`gitlab_rails['backup_path']`. The default is `/var/opt/gitlab/backups`:
```shell ```shell
sudo cp 1393513186_gitlab_backup.tar /var/opt/gitlab/backups/ sudo cp 1393513186_gitlab_backup.tar /var/opt/gitlab/backups/
``` ```
Next, restore the backup by running the restore command. You need to specify the Stop the processes that are connected to the database. The rest of GitLab
timestamp of the backup you are restoring. should remain running:
```shell ```shell
# Stop processes that are connected to the database sudo gitlab-ctl start
sudo gitlab-ctl stop unicorn sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq sudo gitlab-ctl stop sidekiq
```
# This command will overwrite the contents of your GitLab database! Verify that only unicorn and sidekiq are stopped:
sudo gitlab-rake gitlab:backup:restore BACKUP=1393513186
# Start GitLab ```shell
sudo gitlab-ctl start sudo gitlab-ctl status
```
# Check GitLab Next, restore the backup by running the restore command. You need to specify the
sudo gitlab-rake gitlab:check SANITIZE=true timestamp of the backup you are restoring.
```shell
# This command will overwrite the contents of your GitLab database!
sudo gitlab-rake gitlab:backup:restore BACKUP=1393513186
``` ```
If there is a GitLab version mismatch between your backup tar file and the installed If there is a GitLab version mismatch between your backup tar file and the installed
version of GitLab, the restore command will abort with an error. Install a package for version of GitLab, the restore command will abort with an error. Install a package for
the [required version](https://www.gitlab.com/downloads/archives/) and try again. the [required version](https://www.gitlab.com/downloads/archives/) and try again.
Restart unicorn and sidekiq:
```shell
sudo gitlab-ctl start
```
Check GitLab:
```shell
sudo gitlab-rake gitlab:check SANITIZE=true
```
## Configure cron to make daily backups ## Configure cron to make daily backups
### For installation from source: ### For installation from source:
...@@ -345,31 +363,32 @@ Add the following lines at the bottom: ...@@ -345,31 +363,32 @@ Add the following lines at the bottom:
The `CRON=1` environment setting tells the backup script to suppress all progress output if there are no errors. The `CRON=1` environment setting tells the backup script to suppress all progress output if there are no errors.
This is recommended to reduce cron spam. This is recommended to reduce cron spam.
### For omnibus installations ### For Omnibus installations
To schedule a cron job that backs up your repositories and GitLab metadata, use the root user: Edit the crontab for user `git`:
``` ```shell
sudo su - sudo crontab -e -u git
crontab -e
``` ```
There, add the following line to schedule the backup for everyday at 2 AM: Add the following line to schedule a backup of your repositories and GitLab
metadata every day at 2 AM. Note the empty line after the command:
``` ```
0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1 0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
``` ```
You may also want to set a limited lifetime for backups to prevent regular You may also want to set a limited lifetime for backups to prevent regular
backups using all your disk space. To do this add the following lines to backups from consuming too much disk space. To do this add the following lines to
`/etc/gitlab/gitlab.rb` and reconfigure: `/etc/gitlab/gitlab.rb` and reconfigure:
``` ```ruby
# limit backup lifetime to 7 days - 604800 seconds # limit backup lifetime to 7 days - 604800 seconds
gitlab_rails['backup_keep_time'] = 604800 gitlab_rails['backup_keep_time'] = 604800
``` ```
NOTE: This cron job does not [backup your omnibus-gitlab configuration](#backup-and-restore-omnibus-gitlab-configuration) or [SSH host keys](https://superuser.com/questions/532040/copy-ssh-keys-from-one-server-to-another-server/532079#532079). NOTE: This cron job does not [back up your omnibus-gitlab configuration](#backup-and-restore-omnibus-gitlab-configuration) or [SSH host keys](https://superuser.com/questions/532040/copy-ssh-keys-from-one-server-to-another-server/532079#532079).
## Alternative backup strategies ## Alternative backup strategies
......
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