Did you know that you can navigate the posts by swiping left and right?

How To Backup And Restore Gitlab In A New Server

26 Dec 2016 . category: devops . Comments
#git #gitlab #backup #devops #restore

An application data backup creates an archive file that contains the database, all repositories and all attachments. This archive will be saved in backup_path, which is specified in the config/gitlab.yml file. The filename will be [TIMESTAMP]_gitlab_backup.tar, where TIMESTAMP identifies the time at which each backup was created.

You can only restore a backup to exactly the same version of GitLab on which it was created. The best way to migrate your repositories from one server to another is through backup restore.

To restore a backup, you will also need to restore /etc/gitlab/gitlab-secrets.json (for omnibus packages) and /etc/gitlab/gitlab-secret.js (for installations from source). This file contains the database encryption key and CI secret variables used for two-factor authentication. If you fail to restore this encryption key file along with the application data backup, users with two-factor authentication enabled will lose access to your GitLab server. ###Create a backup of the gitlab system Use this command if you’ve installed GitLab with the Omnibus package:


sudo gitlab-rake gitlab:backup:create

Use this if you’ve installed GitLab from source:


sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production

If you are running GitLab within a Docker container, you can run the backup from the host:


docker exec -t  gitlab-rake gitlab:backup:create
</code></pre>
You can specify that portions of the application data be skipped using the environment variable SKIP. You can skip:

db (database)
uploads (attachments)
repositories (Git repositories data)
builds (CI build output logs)
artifacts (CI build artifacts)
lfs (LFS objects)
registry (Container Registry images)
Separate multiple data types to skip using a comma. For example:

sudo gitlab-rake gitlab:backup:create SKIP=db,uploads
###Restore a previously created backup - Restore /etc/gitlab/gitlab.rb and /etc/gitlab/gitlab-secrets.json - Note: that you need to run gitlab-ctl reconfigure after changing gitlab-secrets.json - Restore a previously backup

sudo service gitlab stop

bundle exec rake gitlab:backup:restore RAILS_ENV=production
Options:

BACKUP=timestamp_of_backup (required if more than one backup exists)
force=yes (do not ask if the authorized_keys file should get regenerated)

Me

Harry Nguyen is an awesome person. Abosolutely true!.