How to Create the Backup and Restore the Backup In Gitlab
- 00:32 gitlab-rake gitlab:backup:create
- 00:58 gitlab-rake gitlab:backup:create SKIP = db,uploads
- 01:35 cd /var/opt/gitlab/backups/
- 01:45 ls -la
- 02:13 gitlab-ctl stop unicron
- 02:29 gitlab-ctl stop sidekiq
- 02:48 gitlab-ctl stop
- 03:15 gitlab-rake gitlab:backup:restore BACKUP=1564173006_2019_07_27_12.1.0
- 03:54 gitlab-ctl start
- 04:12 gitlab-rake gitlab:check SANITIZE=true
How To Create The Backup And Restore The backup In Gitlab
GitLab is a free git repository management application based on Ruby on Rails. In this tutorial We are going to cover how to create the 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
2019-07-27 01:59:58 +0530 -- Dumping database ...
Dumping PostgreSQL database gitlabhq_production ... [DONE]
2019-07-27 02:00:05 +0530 -- done
2019-07-27 02:00:05 +0530 -- Dumping repositories ...
2019-07-27 02:00:06 +0530 -- done
2019-07-27 02:00:06 +0530 -- Dumping uploads ...
2019-07-27 02:00:06 +0530 -- done
2019-07-27 02:00:06 +0530 -- Dumping builds ...
2019-07-27 02:00:06 +0530 -- done
2019-07-27 02:00:06 +0530 -- Dumping artifacts ...
2019-07-27 02:00:06 +0530 -- done
2019-07-27 02:00:06 +0530 -- Dumping pages ...
.
.
.
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.
Also, you can skip some fields while taking backup. All you need to do is to run the following command,
root@linuxhelp:~# gitlab-rake gitlab:backup:create SKIP = db,uploads
2019-07-27 02:01:32 +0530 -- Dumping database ...
Dumping PostgreSQL database gitlabhq_production ... [DONE]
2019-07-27 02:01:33 +0530 -- done
2019-07-27 02:01:33 +0530 -- Dumping repositories ...
2019-07-27 02:01:34 +0530 -- done
2019-07-27 02:01:34 +0530 -- Dumping uploads ...
.
.
.
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.
rake aborted!
Don't know how to build task 'SKIP' (See the list of available tasks with `rake --tasks`)
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
(See full trace by running task with --trace)
Enter into the default backup location
root@linuxhelp:~# cd /var/opt/gitlab/backups/
List out the files
root@linuxhelp:/var/opt/gitlab/backups# ls -la
total 248
drwx------ 2 git root 4096 Jul 27 02:01 .
drwxr-xr-x 21 root root 4096 Jul 23 06:43 ..
-rw------- 1 git git 122880 Jul 27 02:00 1564173006_2019_07_27_12.1.0_gitlab_backup.tar
-rw------- 1 git git 122880 Jul 27 02:01 1564173094_2019_07_27_12.1.0_gitlab_backup.tar
To start the restore process stop the unicorn service by running the following command.
root@linuxhelp:~# gitlab-ctl stop unicron
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
ok: down: alertmanager: 0s, normally up
ok: down: gitaly: 0s, 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: 0s, normally up
ok: down: redis-exporter: 1s, normally up
ok: down: sidekiq: 41s, normally up
ok: down: unicorn: 0s, normally up
To Restore
You can restore the backup by running the following command.
root@linuxhelp:~# gitlab-rake gitlab:backup:restore BACKUP=1564173006_2019_07_27_12.1.0
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.
Do you want to continue (yes/no)? yes
Removing all tables. Press `Ctrl-C` within 5 seconds to abort
2019-07-27 02:08:47 +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)
Now you can start the GitLab service by running the following command.
root@linuxhelp:~# gitlab-ctl start
ok: run: alertmanager: (pid 38710) 0s
ok: run: gitaly: (pid 38712) 0s
ok: run: gitlab-monitor: (pid 38721) 1s
ok: run: gitlab-workhorse: (pid 38731) 0s
ok: run: grafana: (pid 38740) 1s
ok: run: logrotate: (pid 38753) 0s
ok: run: nginx: (pid 38762) 1s
ok: run: node-exporter: (pid 38767) 0s
ok: run: postgres-exporter: (pid 38776) 1s
ok: run: postgresql: (pid 38790) 0s
ok: run: prometheus: (pid 38792) 0s
ok: run: redis: (pid 38794) 1s
ok: run: redis-exporter: (pid 38804) 0s
ok: run: sidekiq: (pid 38815) 0s
ok: run: unicorn: (pid 38821) 1s
Use the following command to check configuration status of GitLab.
root@linuxhelp:~# 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
Check GitLab API access: FAILED: Failed to connect to internal API
gitlab-shell self-check failed
Try fixing it:
Make sure GitLab is running;
Check the gitlab-shell configuration file:
sudo -u git -H editor /opt/gitlab/embedded/service/gitlab-shell/config.yml
Please fix the error above and rerun the checks.
.
.
.
Init script up-to-date? ... skipped (omnibus-gitlab has no init script)
Projects have namespace: ... can't check, you have no projects
Redis version >= 2.8.0? ... yes
Ruby version >= 2.5.3 ? ... yes (2.6.3)
Git version >= 2.21.0 ? ... yes (2.21.0)
Git user has default SSH configuration? ... yes
Active users: ... 1
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
With this the method of How to create the backup and restore the backup in gitlab comes to end
Comments ( 0 )
No comments available