How to Manage Backup and Restore in Gitlab
To Manage Backup and Restore in GitLab
GitLab is a free git repository management application based on Ruby on Rails. In our previous articles related to GitLab, we covered the methods to create a group and to add users in a group in GitLab. In this tutorial am going to teach how to create backup and restore the backup in Gitlab.
To backup
You can take a complete GitLab backup by running the following command.
[root@linuxhelp ~]# gitlab-rake gitlab:backup:create
Dumping database ...
[SKIPPED]
Dumping repositories ...
.
.
.
done
done
Deleting old backups ... skipping
Also, you can skip some fields while taking backup. All you need to do is to run the following command, which when used skips the entered fields and takes backup of the other ones.
[root@linuxhelp ~]# gitlab-rake gitlab:backup:create SKIP = db,uploads
Dumping database ...
[SKIPPED]
Dumping repositories ...
.
.
.
done
done
Deleting old backups ... skipping
Backup is stored in default location of GitLab at /var/opt/gitlab/backups
[root@linuxhelp backups]#ls
1489353876_2017_03_13_gitlab_backup.tar
Now you should stop the unicorn service by running the following command.
[root@linuxhelp~]# gitlab-ctl stop unicorn
ok: down: unicorn: 0s, normally up
Also, stop the sidekiq service as follows.
[root@linuxhelp~]# gitlab-ctl stop sidekiq
ok: down: sidekiq: 0s, normally up
Once it is done, check the status of GitLab as follows.
[root@linuxhelp~]# gitlab-ctl stop
run: gitlab-workhorse: (pid 1253) 12597s run: log: (pid 1250) 12597s
run: logrotate: (pid 17696) 1795s run: log: (pid 1257) 12597s
run: nginx: (pid 1254) 12597s run: log: (pid 1251) 12597s
run: postgresql: (pid 1261) 12597s run: log: (pid 1255) 12597s
run: redis: (pid 1259) 12598s run: log: (pid 1256) 12598s
run: sidekiq: (pid 7052) 9451s run: log: (pid 1249) 12598s
down: unicorn: 127s, normally up run: log: (pid 1260) 12598s
To Restore
You can restore the backup by running the following command.
[root@ linuxhelp~]# gitlab-rake gitlab:backup:restore BACKUP=1489353876_2017_03_13
Now you can start the GitLab service by running the following command.
[root@localhost backups]# gitlab-ctl start
ok: run: gitlab-workhorse: (pid 1253) 12771s
ok: run: logrotate: (pid 17696) 1969s
ok: run: nginx: (pid 1254) 12771s
ok: run: postgresql: (pid 1261) 12771s
ok: run: redis: (pid 1259) 12771s
ok: run: sidekiq: (pid 7052) 9624s
ok: run: unicorn: (pid 19637) 0s
Use the following command to check configuration status of GitLab.
[root@linuxhelp~]# gitlab-rake gitlab:check SANITIZE=true
hecking GitLab Shell ...
GitLab Shell version > = 4.1.1 ? ... OK (4.1.1)
Repo base directory exists?
default... yes
.
.
.
Your git bin path is " /opt/gitlab/embedded/bin/git"
Git version > = 2.7.3 ? ... yes (2.10.2)
Active users: 7
Checking GitLab ... Finished
It was pretty simple wasn' t it? You can easily take backup of your GitLab files in times of crisis. We will upload more files on GitLab in the future.
Comments ( 0 )
No comments available