How to Create and Restore a Backup in Gitlab-CE 12.0.3 on CentOS 7.6
- 00:21 vim /etc/gitlab/gitlab.rb
- 00:38 cd /opt/project1
- 00:51 gitlab-rake gitlab:backup:create
- 01:11 gitlab-ctl stop unicorn
- 01:15 gitlab-ctl stop sidekiq
- 01:20 gitlab-ctl stop
- 01:43 gitlab-rake gitlab:backup:restore BACKUP=1564476430_2019_07_30_12.0.3
- 02:03 gitlab-ctl restart
- 02:17 gitlab-rake gitlab:check SANITIZE=true
How to Create And Restore A Backup In Gitlab-CE 12.0.3 On CentOS 7.6
Backup Creation Process:
Navigate to GitLab configuration file to verify the GitLab backup location as follows
[root@linuxhelp ~]# vim /etc/gitlab/gitlab.rb
gitlab_rails['backup_path'] = "/opt/project1/"
Navigate to backup location /opt/project as follows
[root@linuxhelp ~]# cd /opt/project1
Create a backup using rake command
[root@linuxhelp project1]# gitlab-rake gitlab:backup:create
2019-07-30 14:17:07 +0530 -- Dumping database ...
Dumping PostgreSQL database gitlabhq_production ... [DONE]
2019-07-30 14:17:10 +0530 -- done
2019-07-30 14:17:10 +0530 -- Dumping repositories ...
.
.
.
.
done
Deleting old backups ... skipping
Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data
and are not included in this backup. You will need these files to restore a backup.
Please back them up manually.
Backup task is done.
List the directories to check the backup file
[root@linuxhelp project1]# ls -la
total 132
drwx------ 2 git root 60 Jul 30 14:17 .
drwxr-xr-x. 5 root root 46 Jul 29 07:55 ..
w------- 1 git git 133120 Jul 30 14:17 1564476430_2019_07_30_12.0.3_gitlab_backup.tar
BackUp Restore Process
Stop the service of unicorn and sidekiq as follows
oot@linuxhelp project1]# gitlab-ctl stop unicorn
ok: down: unicorn: 0s, normally up
root@linuxhelp project1]# gitlab-ctl stop sidekiq
ok: down: sidekiq: 1s, normally up
Stop the service of gitlab as follows
root@linuxhelp project1]# gitlab-ctl stop
ok: down: alertmanager: 0s, normally up
ok: down: gitaly: 1s, normally up
ok: down: gitlab-monitor: 0s, normally up
ok: down: gitlab-workhorse: 0s, normally up
ok: down: grafana: 0s, normally up
ok: down: logrotate: 0s, normally up
ok: down: nginx: 1s, normally up
ok: down: node-exporter: 0s, normally up
ok: down: postgres-exporter: 1s, normally up
ok: down: postgresql: 0s, normally up
ok: down: prometheus: 0s, normally up
ok: down: redis: 1s, normally up
ok: down: redis-exporter: 0s, normally up
ok: down: sidekiq: 18s, normally up
ok: down: unicorn: 35s, normally up
Now restore the backup by executing the following command
root@linuxhelp project1]# gitlab-rake gitlab:backup:restore BACKUP=1564476430_2019_07_30_12.0.3
Unpacking backup ... done
Before restoring the database, we will remove all existing
tables to avoid future upgrade problems. Be aware that if you have
custom tables in the GitLab database these tables and all data will be
removed.
you want to continue (yes/no)? yes
Removing all tables. Press `Ctrl-C` within 5 seconds to abort
2019-07-30 14:19:43 +0530 -- Cleaning the database ...
rake aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:27:in `block (3 levels) in <top (required)>'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:56:in `block (3 levels) in <top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Tasks: TOP => gitlab:db:drop_tables
(See full trace by running task with --trace)
List the directories to verify the files
oot@linuxhelp project1]# ls -la
total 156
drwx------ 4 git root 225 Jul 30 14:19 .
drwxr-xr-x. 5 root root 46 Jul 29 07:55 ..
-rw------- 1 git git 133120 Jul 30 14:17 1564476430_2019_07_30_12.0.3_gitlab_backup.tar
-rw------- 1 git git 149 Jul 30 14:17 artifacts.tar.gz
-rw-r--r-- 1 git git 190 Jul 30 14:17 backup_information.yml
-rw------- 1 git git 151 Jul 30 14:17 builds.tar.gz
drwxr-xr-x 2 git git 29 Jul 30 14:17 db
-rw------- 1 git git 151 Jul 30 14:17 lfs.tar.gz
-rw------- 1 git git 155 Jul 30 14:17 pages.tar.gz
drwx------ 2 git git 6 Jul 30 14:17 repositories
-rw------- 1 git git 151 Jul 30 14:17 uploads.tar.gz
Now restart the service of gitlab as follows
oot@linuxhelp project1]# gitlab-ctl restart
ok: run: alertmanager: (pid 29134) 0s
ok: run: gitaly: (pid 29143) 1s
ok: run: gitlab-monitor: (pid 29166) 0s
ok: run: gitlab-workhorse: (pid 29171) 1s
ok: run: grafana: (pid 29178) 0s
ok: run: logrotate: (pid 29186) 0s
ok: run: nginx: (pid 29192) 1s
ok: run: node-exporter: (pid 29207) 0s
ok: run: postgres-exporter: (pid 29211) 1s
ok: run: postgresql: (pid 29216) 0s
ok: run: prometheus: (pid 29218) 1s
ok: run: redis: (pid 29233) 0s
ok: run: redis-exporter: (pid 29238) 1s
ok: run: sidekiq: (pid 29243) 0s
ok: run: unicorn: (pid 29249) 1s
Sanitize the Database and also check the status of database
root@linuxhelp project1]# gitlab-rake gitlab:check SANITIZE=true
Checking GitLab subtasks ...
Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 9.3.0 ? ... OK (9.3.0)
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
.
.
.
.
.
Git version >= 2.21.0 ? ... yes (2.21.0)
Git user has default SSH configuration? ... yes
Active users: ... 2
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
With this,Gitlab-CE 12.0.3 backup has been created and restored successfully On CentOS 7.6
Comments ( 0 )
No comments available