{"id":881,"date":"2016-05-13T04:49:37","date_gmt":"2016-05-13T04:49:37","guid":{"rendered":"http:\/\/cloudkul.com\/blog\/?p=881"},"modified":"2017-06-14T11:34:05","modified_gmt":"2017-06-14T11:34:05","slug":"automate-gitlab-backups-within-amazon-s3-bucket","status":"publish","type":"post","link":"https:\/\/cloudkul.com\/blog\/automate-gitlab-backups-within-amazon-s3-bucket\/","title":{"rendered":"Automate Gitlab Backups Within Amazon S3 Bucket"},"content":{"rendered":"<p>Every day data keeps adding to your GitLab application&#8217;s production server and all is working fine. But you don&#8217;t realize that your server can crash due to a lot of reasons and sometimes by the time you realize all your data is lost.\u00a0So, taking backup of your applications is as important as adding new features to them and it should be a part of maintaining your application.<\/p>\n<p>Manually taking repeatedly backups sometimes becomes too boring. So, automating the whole process of taking the backup of your GitLab repositories is a good idea. But the smart approach is to keep your backup archive in Amazon S3 bucket rather than gitlab server itself or in any other local repository server because if server crashes then your backups are lost too.<\/p>\n<p><strong>Creating Gitlab Backup :<\/strong><\/p>\n<p>A backup creates an archive file that contains the database, all repositories and all attachments. The filename will be [TIMESTAMP]_gitlab_backup.tar . To create backup use the following command if you&#8217;ve installed GitLab with the Omnibus package :-<\/p>\n<pre class=\"lang:default decode:true\">sudo gitlab-rake gitlab:backup:create\r\n<\/pre>\n<p><span style=\"line-height: 1.5\">Backup archive location :-<\/span><\/p>\n<pre class=\"lang:default decode:true \">\/var\/opt\/gitlab\/backups\/<\/pre>\n<p><strong>Upload backups to cloud storage ( Amazon S3 bucket) :<\/strong><\/p>\n<p>For omnibus packages, make the following entries in \/etc\/gitlab\/gitlab.rb file :-<\/p>\n<pre class=\"lang:default decode:true \">gitlab_rails['manage_backup_path'] = true\r\ngitlab_rails['backup_path'] = \"\/var\/opt\/gitlab\/backups\"\r\ngitlab_rails['backup_archive_permissions'] = 0644\u00a0\r\ngitlab_rails['backup_pg_schema'] = 'public'\r\ngitlab_rails['backup_keep_time'] = 604800 # this may vary\r\ngitlab_rails['backup_upload_connection'] = {\r\n'provider' =&gt; 'AWS',\r\n'region' =&gt; 'us-west-2', # specify the region in which your bucket is created\r\n'aws_access_key_id' =&gt; 'AdjkIAJFs2F3FYWRHXRd', # specify the access key of your IAM user\r\n'aws_secret_access_key' =&gt; 'Mjfofiofipfojekjt4R+\/IShmAC35WFdwdjw6Eof'\u00a0# specify the secret access key of your IAM user\r\n}\r\ngitlab_rails['backup_upload_remote_directory'] = 'test-bucket' # your bucket name<\/pre>\n<p>Next step is to reconfigure your gitlab after making these changes. Run the following command :-<\/p>\n<pre class=\"lang:default decode:true \">gitlab-ctl reconfigure<\/pre>\n<p><strong>Setup Cron :-<\/strong><\/p>\n<p>Lets setup a cron job to create gitlab backup at 5 am everyday :-<\/p>\n<pre class=\"lang:default decode:true\">0 5 * * * \/usr\/bin\/gitlab-rake \u00a0 gitlab:backup:create\r\n<\/pre>\n<p>Once you are done with the above mentioned gitlab configuration, this cron job will simply create a backup of your gitlab everyday at 5AM and sync that backup to your cloud storage location i.e. Amazon S3 bucket specified in gitlab.rb file. Therefore, you don&#8217;t have to bother about manually taking everyday backups and maintain a local repo server for storing those backups. Hope this helps !<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/cloudkul.com\/contact\/\">IN CASE OF ANY QUERY, CONTACT US<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Every day data keeps adding to your GitLab application&#8217;s production server and all is working <a class=\"text-primary\" title=\"read more\" href=\"https:\/\/cloudkul.com\/blog\/automate-gitlab-backups-within-amazon-s3-bucket\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":5,"featured_media":911,"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":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Automate Gitlab Backups Within Amazon S3 Bucket - 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\/automate-gitlab-backups-within-amazon-s3-bucket\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Automate Gitlab Backups Within Amazon S3 Bucket - Cloudkul\" \/>\n<meta property=\"og:description\" content=\"Every day data keeps adding to your GitLab application&#8217;s production server and all is working [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudkul.com\/blog\/automate-gitlab-backups-within-amazon-s3-bucket\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudkul\" \/>\n<meta property=\"article:published_time\" content=\"2016-05-13T04:49:37+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-06-14T11:34:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/05\/Automate-Gitlab-Backup-within-AmazonS3-Buckets.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=\"Naina Johari\" \/>\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\/automate-gitlab-backups-within-amazon-s3-bucket\/\",\"url\":\"https:\/\/cloudkul.com\/blog\/automate-gitlab-backups-within-amazon-s3-bucket\/\",\"name\":\"Automate Gitlab Backups Within Amazon S3 Bucket - Cloudkul\",\"isPartOf\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\"},\"datePublished\":\"2016-05-13T04:49:37+00:00\",\"dateModified\":\"2017-06-14T11:34:05+00:00\",\"author\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/38f7cddff574c7fe989d6ca2df61fc57\"},\"breadcrumb\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/automate-gitlab-backups-within-amazon-s3-bucket\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudkul.com\/blog\/automate-gitlab-backups-within-amazon-s3-bucket\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudkul.com\/blog\/automate-gitlab-backups-within-amazon-s3-bucket\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Automate Gitlab Backups Within Amazon S3 Bucket\"}]},{\"@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\/38f7cddff574c7fe989d6ca2df61fc57\",\"name\":\"Naina Johari\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c7a0be3afff58963975900f809e57046?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c7a0be3afff58963975900f809e57046?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"caption\":\"Naina Johari\"},\"url\":\"https:\/\/cloudkul.com\/blog\/author\/naina-johari379\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Automate Gitlab Backups Within Amazon S3 Bucket - 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\/automate-gitlab-backups-within-amazon-s3-bucket\/","og_locale":"en_US","og_type":"article","og_title":"Automate Gitlab Backups Within Amazon S3 Bucket - Cloudkul","og_description":"Every day data keeps adding to your GitLab application&#8217;s production server and all is working [...]","og_url":"https:\/\/cloudkul.com\/blog\/automate-gitlab-backups-within-amazon-s3-bucket\/","og_site_name":"Cloudkul","article_published_time":"2016-05-13T04:49:37+00:00","article_modified_time":"2017-06-14T11:34:05+00:00","og_image":[{"width":848,"height":422,"url":"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/05\/Automate-Gitlab-Backup-within-AmazonS3-Buckets.png","type":"image\/png"}],"author":"Naina Johari","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/cloudkul.com\/blog\/automate-gitlab-backups-within-amazon-s3-bucket\/","url":"https:\/\/cloudkul.com\/blog\/automate-gitlab-backups-within-amazon-s3-bucket\/","name":"Automate Gitlab Backups Within Amazon S3 Bucket - Cloudkul","isPartOf":{"@id":"https:\/\/cloudkul.com\/blog\/#website"},"datePublished":"2016-05-13T04:49:37+00:00","dateModified":"2017-06-14T11:34:05+00:00","author":{"@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/38f7cddff574c7fe989d6ca2df61fc57"},"breadcrumb":{"@id":"https:\/\/cloudkul.com\/blog\/automate-gitlab-backups-within-amazon-s3-bucket\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudkul.com\/blog\/automate-gitlab-backups-within-amazon-s3-bucket\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cloudkul.com\/blog\/automate-gitlab-backups-within-amazon-s3-bucket\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Automate Gitlab Backups Within Amazon S3 Bucket"}]},{"@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\/38f7cddff574c7fe989d6ca2df61fc57","name":"Naina Johari","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c7a0be3afff58963975900f809e57046?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c7a0be3afff58963975900f809e57046?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","caption":"Naina Johari"},"url":"https:\/\/cloudkul.com\/blog\/author\/naina-johari379\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/881"}],"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\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/comments?post=881"}],"version-history":[{"count":9,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/881\/revisions"}],"predecessor-version":[{"id":910,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/881\/revisions\/910"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media\/911"}],"wp:attachment":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media?parent=881"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/categories?post=881"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/tags?post=881"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}