• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

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
5891

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

Tags:
sebastian
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

What is GitLab?

A

GitLab is a web-based project management repository based on Git. It lets you create and manage your projects effectively.

Q

Does GitLab support groups of users?

A

GitLab does support user groups which allow you to group projects into directories and give users access to several projects at once.

Q

Where is Default Backup Location In GitLab?

A

Default Backup Location In GitLab is available in /var/opt/gitlab/backups.

Q

Does GitLab provide a way to block project creation for certain users?

A

GitLab admins can set a project limit for each user. If the limit is set to 0 the user cannot create any projects.

Q

What is the use of gitlab?

A

GitLab is a free git repository management application based on Ruby on Rails.

Related Tutorials in How to Create the Backup and Restore the Backup In Gitlab

Related Tutorials in How to Create the Backup and Restore the Backup In Gitlab

How to add local folder to a GitLab project
How to add local folder to a GitLab project
Apr 20, 2017
How to reset gitlab admin password
How to reset gitlab admin password
Mar 30, 2017
How to Install and configure GitLab runner on centos 7
How to Install and configure GitLab runner on centos 7
Oct 22, 2021
How to change default backup location in GitLab
How to change default backup location in GitLab
Apr 17, 2017
How to add users to group in GitLab
How to add users to group in GitLab
Feb 15, 2017
How to Change the Administrator Password in GitLab-CE on CentOS 7.6
How to Change the Administrator Password in GitLab-CE on CentOS 7.6
Aug 3, 2019
How to add SSH key to a GitLab account
How to add SSH key to a GitLab account
Apr 22, 2017
How to Create Description Templates for Gitlab Projects
How to Create Description Templates for Gitlab Projects
Mar 28, 2017

Related Forums in How to Create the Backup and Restore the Backup In Gitlab

Related Forums in How to Create the Backup and Restore the Backup In Gitlab

gitlab
baseer class=
How to check gitlab version
Oct 24, 2017
Git
vertonskjelvic class=
error: failed to push some refs to in gitlab
Nov 24, 2017
gitlab
caden class=
Insufficient space in download directory /var/cache/yum/x86_64/6/base/packages
Jul 22, 2019
gitlab
brayden class=
GitLab: The project you were looking for could not be found
May 23, 2017
gitlab
ceriaimmaculate class=
Gitlab : how to rename branch name
Oct 26, 2017
gitlab
otwol class=
502 Error Whoops Gitlab is Taking too much of time to respond
Jul 29, 2019
gitlab
ajinfernando class=
Gitlab : how to switch remote repository URL from ssh to http
Oct 25, 2017
gitlab
otwol class=
How to Check the version of Gitlab-CE 12.0.3 On CentOS 7.6 and Where is it exactly Located
Jul 23, 2019

Related News in How to Create the Backup and Restore the Backup In Gitlab

Related News in How to Create the Backup and Restore the Backup In Gitlab

Gitlab assures its users of data recovery post data loss incident
Gitlab assures its users of data recovery post data loss incident
Feb 4, 2017
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Isaiah ?
What is the use of SUID & SGID commands

How to set the special permissions to the files and folders using SUID and SGID commands...

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.