====== Gitlab backup ======
===== Making backup =====
* block gitlab access (but leave maintenance web page)
* gitlab-ctl deploy-page up
* sudo gitlab-ctl stop unicorn
* sudo gitlab-ctl stop sidekiq
* Store configuration file manually (/etc/gitlab)
* Trigger backup creation
* ''gitlab-rake gitlab:backup:create''
* Start gitlab
* ''gitlab-ctl start''
* ''gitlab-ctl deploy-page down''
Make backup without repository
gitlab-rake gitlab:backup:create SKIP=repositories,uploads
For possible rake tasks to skip see into file ''/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake''.
For now it cane be: ''repositories,db,builds,uploads,artifacts,lfs''
==== Automating backups ====
crontab -e
0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
==== What is in backup ====
Backup file e.g.: ''1462327272_gitlab_backup.tar'' is simple tar archive with example content:
|-- artifacts.tar.gz
|-- backup_information.yml
|-- builds.tar.gz
|-- db
| `-- database.sql.gz
|-- lfs.tar.gz
|-- repositories
| |-- group1
| | |-- http-server.bundle
| | |-- kernel.bundle
| |-- group2
| | |-- buildroot.bundle
| | |-- linux-stable.bundle
| | |-- u-boot.bundle
| | `-- yocto.bundle
| `-- user1
| |-- buildroot.bundle
| |-- linux-stable.bundle
| |-- linux.bundle
| |-- uboot.bundle
`-- uploads.tar.gz
Where .bundle filesa re simple tar archives of bare git repos.
===== Restoring backup =====
* install exactly the same version from backup comes
* to wrap ''initctl'' with ''systemctl'', use [[https://gist.github.com/zorael/8907216]]
* install default gitlab package and make sure it is running
* use `/etc/gitlab` from backup
* run ''gitlab-ctl reconfigure''
* stop gitlab
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop puma
sudo gitlab-ctl stop sidekiq
# Verify
sudo gitlab-ctl status
* Prepare backup file/directory
* Make sure that backup pointed by `gitlab_rails['backup_path']` is owned by `git` user.
* Restore backup
* ''sudo gitlab-backup restore''
* OR ''sudo gitlab-backup restore BACKUP=1393513186''
* Start GitLab
* ''sudo gitlab-ctl start''
* Check GitLab
* ''sudo gitlab-rake gitlab:check SANITIZE=true''