{"id":1300,"date":"2016-10-21T11:10:24","date_gmt":"2016-10-21T11:10:24","guid":{"rendered":"http:\/\/cloudkul.com\/blog\/?p=1300"},"modified":"2017-06-14T11:33:45","modified_gmt":"2017-06-14T11:33:45","slug":"restore-gitlab-backup","status":"publish","type":"post","link":"https:\/\/cloudkul.com\/blog\/restore-gitlab-backup\/","title":{"rendered":"How to restore gitlab from backup"},"content":{"rendered":"<p>Gitlab is a tool for managing git repositories on a centralized server. Sometimes due to some reasons system crashes and we lose our valuable data. Therefore it is necessary to take regular backups of the gitlab server. So in case of any emergency we should be able to restore gitlab server with the backup data as soon as possible. In this tutorial I will show you how to restore a gitlab server from gitlab backup.<\/p>\n<p><strong>Before restoring gitlab you must consider the following points<\/strong>.<\/p>\n<ul>\n<li>Gitlab backup directory is \/var\/opt\/gitlab\/backups . You must put your gitlab backup files in this directory.<\/li>\n<li>Gitlab backup file format should be &#8220;timestamp_gitlab_backup.tar&#8221;<\/li>\n<li>Example of valid gitlab backup file name is \u00a0&#8220;1468787928_gitlab_backup.tar&#8221;. where 1468787928 is the timestamp.<\/li>\n<li>Owner of the backup file should be git.<\/li>\n<li>You should restore the backup to the proper version of gitlab. If you have taken the backup from gitlab version 7.7.2, you should use the backup in version 7.7.2. You should not try to restore the backup in other versions.<\/li>\n<\/ul>\n<p><span style=\"text-decoration: underline\"><strong>Restoring gitlab from backup<\/strong><\/span><\/p>\n<p>Put your backup file in <strong>\/var\/opt\/gitlab\/backups\/<\/strong> and change the ownership to git. To change the ownership, run the following command.<\/p>\n<pre class=\"lang:default decode:true\">chown -R git:git \/var\/opt\/gitlab\/backups<\/pre>\n<p>I have already put the back up file in \/var\/opt\/gitlab\/backups\/<\/p>\n<p><a href=\"http:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/09\/gitlab.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1301\" src=\"http:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/09\/gitlab.png\" alt=\"gitlab\" width=\"719\" height=\"113\" \/><\/a><\/p>\n<p>To restore a gitlab back up, run the following command.<\/p>\n<pre class=\"lang:default decode:true\">gitlab-rake gitlab:backup:restore 1468787928_gitlab_backup.tar<\/pre>\n<p>Sometimes you can get this error. To resolve this error you must increase the RAM of your system and try again.<\/p>\n<p><a href=\"http:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/09\/gitlab-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1302\" src=\"http:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/09\/gitlab-2.png\" alt=\"gitlab 2\" width=\"720\" height=\"129\" \/><\/a><\/p>\n<p>At last it will ask for rebuild an authorized_keys file. Select &#8220;no&#8221;.<\/p>\n<p><a href=\"http:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/09\/gitlab-4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1303\" src=\"http:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/09\/gitlab-4.png\" alt=\"gitlab 4\" width=\"723\" height=\"161\" \/><\/a><\/p>\n<p>Now, you have successfully restored your gitlab from the backup.<\/p>\n<p>Suppose your backup filename is <strong>backup.tar<\/strong>. In this case you can not restore your data. Don&#8217;t worry, you have to only change the name to proper format. All you have to do is to get the exact timestamp of backup file.<\/p>\n<p>Extract your backup file and read the <strong>backup_information.yml<\/strong> file.<\/p>\n<p><strong>backup_information.yml<\/strong> file is generally contains the following.<\/p>\n<pre class=\"lang:default decode:true\">:db_version: '20150116234544'\r\n:backup_created_at: 2016-07-17 20:38:48.840076422 +00:00\r\n:gitlab_version: 7.7.2\r\n:tar_version: tar (GNU tar) 1.27.1<\/pre>\n<p>Now, you know when the backup was created. You need to generate the timestamp from these details.You need to focus the line <strong>backup_created_at<\/strong>. For generating timestamp go to\u00a0<a href=\"http:\/\/www.timestampgenerator.com\/\" target=\"_blank\">http:\/\/www.timestampgenerator.com\/<\/a><\/p>\n<p>Enter all the details.<\/p>\n<p><a href=\"http:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/10\/timestamp.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1463\" src=\"http:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/10\/timestamp.png\" alt=\"timestamp\" width=\"840\" height=\"415\" \/><\/a><\/p>\n<p>After you click on generate, it will show you the timestamp of the backup file.<a href=\"http:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/10\/generate_timestamp.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1464\" src=\"http:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/10\/generate_timestamp.png\" alt=\"generate_timestamp\" width=\"831\" height=\"518\" \/><\/a>In my case the timestamp is <strong>1468701528<\/strong>.<\/p>\n<p>So I should rename my file to\u00a0<strong>1468701528_gitlab_backup.tar<\/strong><\/p>\n<pre class=\"lang:default decode:true\">mv backup.tar 1468701528_gitlab_backup.tar<\/pre>\n<p>Now, the name is in proper format. You can able to restore your gitlab from the backup.<\/p>\n<p>If you have any doubts regarding restoration of gitlab backup, you can ask me in the comment.<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/cloudkul.com\/contact\/\" target=\"_blank\"> IN CASE OF ANY QUERY,CONTACT US<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Gitlab is a tool for managing git repositories on a centralized server. Sometimes due to <a class=\"text-primary\" title=\"read more\" href=\"https:\/\/cloudkul.com\/blog\/restore-gitlab-backup\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":8,"featured_media":1486,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[61,53],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to restore gitlab from backup - Cloudkul<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudkul.com\/blog\/restore-gitlab-backup\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to restore gitlab from backup - Cloudkul\" \/>\n<meta property=\"og:description\" content=\"Gitlab is a tool for managing git repositories on a centralized server. Sometimes due to [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudkul.com\/blog\/restore-gitlab-backup\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudkul\" \/>\n<meta property=\"article:published_time\" content=\"2016-10-21T11:10:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-06-14T11:33:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/10\/Restore-Gitlab-From-Backup.png\" \/>\n\t<meta property=\"og:image:width\" content=\"848\" \/>\n\t<meta property=\"og:image:height\" content=\"422\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"suranjan horrow\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudkul.com\/blog\/restore-gitlab-backup\/\",\"url\":\"https:\/\/cloudkul.com\/blog\/restore-gitlab-backup\/\",\"name\":\"How to restore gitlab from backup - Cloudkul\",\"isPartOf\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\"},\"datePublished\":\"2016-10-21T11:10:24+00:00\",\"dateModified\":\"2017-06-14T11:33:45+00:00\",\"author\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/a653191c790a89b07d4b4aaefc3e2809\"},\"breadcrumb\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/restore-gitlab-backup\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudkul.com\/blog\/restore-gitlab-backup\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudkul.com\/blog\/restore-gitlab-backup\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to restore gitlab from backup\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\",\"url\":\"https:\/\/cloudkul.com\/blog\/\",\"name\":\"Cloudkul\",\"description\":\"Host your eCommerce Store on AWS with Optimized Performance\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cloudkul.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/a653191c790a89b07d4b4aaefc3e2809\",\"name\":\"suranjan horrow\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/dfd7f87bc7d62c1426e1f4c07653ff00?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/dfd7f87bc7d62c1426e1f4c07653ff00?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"caption\":\"suranjan horrow\"},\"sameAs\":[\"http:\/\/webkul.com\"],\"url\":\"https:\/\/cloudkul.com\/blog\/author\/suranjan-horrow869\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to restore gitlab from backup - Cloudkul","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cloudkul.com\/blog\/restore-gitlab-backup\/","og_locale":"en_US","og_type":"article","og_title":"How to restore gitlab from backup - Cloudkul","og_description":"Gitlab is a tool for managing git repositories on a centralized server. Sometimes due to [...]","og_url":"https:\/\/cloudkul.com\/blog\/restore-gitlab-backup\/","og_site_name":"Cloudkul","article_published_time":"2016-10-21T11:10:24+00:00","article_modified_time":"2017-06-14T11:33:45+00:00","og_image":[{"width":848,"height":422,"url":"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/10\/Restore-Gitlab-From-Backup.png","type":"image\/png"}],"author":"suranjan horrow","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/cloudkul.com\/blog\/restore-gitlab-backup\/","url":"https:\/\/cloudkul.com\/blog\/restore-gitlab-backup\/","name":"How to restore gitlab from backup - Cloudkul","isPartOf":{"@id":"https:\/\/cloudkul.com\/blog\/#website"},"datePublished":"2016-10-21T11:10:24+00:00","dateModified":"2017-06-14T11:33:45+00:00","author":{"@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/a653191c790a89b07d4b4aaefc3e2809"},"breadcrumb":{"@id":"https:\/\/cloudkul.com\/blog\/restore-gitlab-backup\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudkul.com\/blog\/restore-gitlab-backup\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cloudkul.com\/blog\/restore-gitlab-backup\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to restore gitlab from backup"}]},{"@type":"WebSite","@id":"https:\/\/cloudkul.com\/blog\/#website","url":"https:\/\/cloudkul.com\/blog\/","name":"Cloudkul","description":"Host your eCommerce Store on AWS with Optimized Performance","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudkul.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/a653191c790a89b07d4b4aaefc3e2809","name":"suranjan horrow","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/dfd7f87bc7d62c1426e1f4c07653ff00?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/dfd7f87bc7d62c1426e1f4c07653ff00?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","caption":"suranjan horrow"},"sameAs":["http:\/\/webkul.com"],"url":"https:\/\/cloudkul.com\/blog\/author\/suranjan-horrow869\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/1300"}],"collection":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/comments?post=1300"}],"version-history":[{"count":27,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/1300\/revisions"}],"predecessor-version":[{"id":1494,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/1300\/revisions\/1494"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media\/1486"}],"wp:attachment":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media?parent=1300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/categories?post=1300"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/tags?post=1300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}