{"id":5156,"date":"2018-08-19T19:34:09","date_gmt":"2018-08-19T19:34:09","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=5156"},"modified":"2018-08-21T08:08:29","modified_gmt":"2018-08-21T08:08:29","slug":"how-to-backup-and-restore-gerrit-server","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-backup-and-restore-gerrit-server\/","title":{"rendered":"How to backup and restore Gerrit server?"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5188\" src=\"http:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2018\/08\/gerrit-server.png\" alt=\"\" width=\"600\" height=\"350\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2018\/08\/gerrit-server.png 600w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2018\/08\/gerrit-server-300x175.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><strong>How to backup and restore gerrit server?<\/strong><\/p>\n<p>There are 3 coponent which should be backed up in gerrit<\/p>\n<ol>\n<li>Repository &#8211; According to me best way to backup the repository is to setup a replication with other gerrit hosting tools using gerrit replication plugins. The steps can be find as below;<\/li>\n<li>Gerrit Database<br \/>\nDepends on the database, you should take the database backup. It can be H2 or mysql&#8230;.<\/li>\n<li>Gerrit Config<br \/>\nRysnc is the best tools to take the entire gerrit site backup.<\/li>\n<\/ol>\n<p><strong>How to replicate Gerrit repository using replication plugins?<\/strong><\/p>\n<p><strong>Step 1- Setup Gerrit Server<\/strong><br \/>\nhttp:\/\/www.devopsschool.com\/tutorial\/gerrit\/gerrit-install-and-configuration.html<\/p>\n<p><strong>Step 2 &#8211; Create a Project in Gerrit<\/strong><\/p>\n<p><strong>Step 3 &#8211; Setup a Developement Machine<\/strong><br \/>\ngit clone http:\/\/admin@35.154.81.167:8080\/a\/prj1 &amp;&amp; (cd prj1 &amp;&amp; curl -kLo `git rev-parse &#8211;git-dir`\/hooks\/commit-msg http:\/\/admin@35.154.81.167:8080\/tools\/hooks\/commit-msg; chmod +x `git rev-parse &#8211;git-dir`\/hooks\/commit-msg)<\/p>\n<p><strong>Step 4: Sample Commits to be done<\/strong><br \/>\n&gt; touch file1.txt;git add .;git commit -m&#8221;adding first version&#8221;<\/p>\n<p><strong>Step 5: Sample push and submit it<\/strong><br \/>\n&gt; git push origin HEAD:refs\/for\/master<\/p>\n<p><strong>Step 6: create it $site_path\/etc\/replication.config<\/strong><\/p>\n<p>Content of the files is &#8211;<br \/>\n[remote &#8220;github&#8221;]<br \/>\nurl = git@github.com:scmgalaxy\/${name}.git<\/p>\n<p>Within each URL value the magic placeholder `${name}` is replaced with the Gerrit project name.<\/p>\n<p><strong>Step 7: Generate a public\/private key<\/strong><\/p>\n<p>&gt; ssh-keygen -t rsa<\/p>\n<p><strong>Step 8: create a &#8220;config&#8221; under \/root\/.ssh<\/strong><\/p>\n<p>Host github.com<br \/>\nUser git<br \/>\nIdentityFile \/root\/.ssh\/id_rsa<br \/>\nStrictHostKeyChecking no<br \/>\nUserKnownHostsFile \/dev\/null<\/p>\n<p><strong>Step 9: Update the public key to github<\/strong><\/p>\n<p><strong>Step 10: Create a repo in Github.com with same name.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to backup and restore gerrit server? There are 3 coponent which should be backed up in gerrit Repository &#8211; According to me best way to backup the repository is to setup a replication with other gerrit hosting tools using gerrit replication plugins. The steps can be find as below; Gerrit Database Depends on the&#8230;<\/p>\n","protected":false},"author":1,"featured_media":5188,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[4994],"tags":[591,945,592,399],"class_list":["post-5156","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-gerrit","tag-backup","tag-gerrit","tag-restore","tag-server"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/5156","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=5156"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/5156\/revisions"}],"predecessor-version":[{"id":5189,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/5156\/revisions\/5189"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/5188"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=5156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=5156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=5156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}