Skip to content

Instantly share code, notes, and snippets.

@arpat
Created June 23, 2016 09:54
Show Gist options
  • Save arpat/6c85e4b5fff921da253dba3047e61940 to your computer and use it in GitHub Desktop.
Save arpat/6c85e4b5fff921da253dba3047e61940 to your computer and use it in GitHub Desktop.
Backup and restore omnibus-gitlab configuration
It is recommended to keep a copy of /etc/gitlab, or at least of /etc/gitlab/gitlab-secrets.json, in a safe place.
All configuration for omnibus-gitlab is stored in /etc/gitlab.
# Example backup command for /etc/gitlab:
# Create a time-stamped .tar file in the current directory.
# The .tar file will be readable only to root.
##sudo sh -c 'umask 0077; tar -cf $(date "+etc-gitlab-%s.tar") -C / etc/gitlab'
Creating an application backup
To create a backup of your repositories and GitLab metadata, follow the backup create documentation:
A backup creates an archive file that contains the database, all repositories and all attachments.
This archive will be saved in backup_path (see config/gitlab.yml). The filename will be [TIMESTAMP]_gitlab_backup.tar.
Backup create will store a tar file in /var/opt/gitlab/backups by default?
If you want to store your GitLab backups in a different directory, add the following setting to /etc/gitlab/gitlab.rb and run sudo gitlab-ctl reconfigure:
#gitlab_rails['backup_path'] = '/mnt/backups'
You need to keep a separate copy of /etc/gitlab/gitlab-secrets.json to ensure the app data cannot be decrypted without intention.
# use this command if you've installed GitLab with the Omnibus package
##sudo gitlab-rake gitlab:backup:create
Restore a previously created backup
You can only restore a backup to exactly the same version of GitLab that you created it on, for example 7.2.1.
You need to have a working GitLab installation before you can perform a restore.
Note that you need to run gitlab-ctl reconfigure after changing gitlab-secrets.json.
Updating from GitLab 6.6 and higher to the latest version
First, download the latest CE or EE (license key required) package to your GitLab server.
Stop services but leave postgresql running for the database migrations and create a backup
##sudo gitlab-ctl stop unicorn
##sudo gitlab-ctl stop sidekiq
##sudo gitlab-ctl stop nginx
##sudo gitlab-rake gitlab:backup:create
Install the latest package
# Debian/Ubuntu:
##sudo dpkg -i gitlab_x.x.x-omnibus.xxx.deb
Reconfigure GitLab (includes running database migrations) and restart all services
##sudo gitlab-ctl reconfigure
##sudo gitlab-ctl restart
Done!
@arpat
Copy link
Author

arpat commented Jun 23, 2016

Quick notes on maintaining gitlab ce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment