diff options
author | Rémy Coutable <remy@rymai.me> | 2016-04-26 17:56:28 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-04-26 17:56:28 +0300 |
commit | 6d9f1e0b1c975f652211cc531a78fd58c1f5ccef (patch) | |
tree | cebdc51daf4ed7ff74c5c76ccf74caa68b93d578 /doc | |
parent | d3aed10d70352c45ae3fe588c38d92da0a6514a7 (diff) | |
parent | e157e971145e585a81fb7c8390b6175b188b4810 (diff) |
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
Diffstat (limited to 'doc')
-rw-r--r-- | doc/raketasks/backup_restore.md | 59 |
1 files changed, 39 insertions, 20 deletions
diff --git a/doc/raketasks/backup_restore.md b/doc/raketasks/backup_restore.md index 4329ac30a1c..25c439b1c65 100644 --- a/doc/raketasks/backup_restore.md +++ b/doc/raketasks/backup_restore.md @@ -295,37 +295,55 @@ Deleting tmp directories...[DONE] ### 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. -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 sudo cp 1393513186_gitlab_backup.tar /var/opt/gitlab/backups/ ``` -Next, restore the backup by running the restore command. You need to specify the -timestamp of the backup you are restoring. +Stop the processes that are connected to the database. The rest of GitLab +should remain running: ```shell -# Stop processes that are connected to the database +sudo gitlab-ctl start sudo gitlab-ctl stop unicorn sudo gitlab-ctl stop sidekiq +``` -# This command will overwrite the contents of your GitLab database! -sudo gitlab-rake gitlab:backup:restore BACKUP=1393513186 +Verify that only unicorn and sidekiq are stopped: -# Start GitLab -sudo gitlab-ctl start +```shell +sudo gitlab-ctl status +``` -# Check GitLab -sudo gitlab-rake gitlab:check SANITIZE=true +Next, restore the backup by running the restore command. You need to specify the +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 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. +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 ### For installation from source: @@ -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. 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`: -``` -sudo su - -crontab -e +```shell +sudo crontab -e -u git ``` -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 + ``` 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: -``` +```ruby # limit backup lifetime to 7 days - 604800 seconds 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 |