{"id":1741,"date":"2017-12-06T05:25:23","date_gmt":"2017-12-06T05:25:23","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=1741"},"modified":"2021-02-27T09:31:10","modified_gmt":"2021-02-27T09:31:10","slug":"svn-mirror-for-live-back-up-high-availability","status":"publish","type":"post","link":"https:\/\/www.scmgalaxy.com\/tutorials\/svn-mirror-for-live-back-up-high-availability\/","title":{"rendered":"SVN mirror for Live back-up &#8211; High Availability"},"content":{"rendered":"<p><strong>vishal_vsh1 created the topic: SVN mirror for Live back-up &#8211; High Availability<\/strong><br \/>\nSVN mirror for Live back-up &#8211; High Availability <\/p>\n<p>Other then taking backup at regular interval, we may want to provide keep live data just to make sure data is highly available.<\/p>\n<p>The best option is to backup Live data as soon as it gets changed.<\/p>\n<p>Here is the trick for the SVN Mirroring.<\/p>\n<p>How to create Repository<br \/>\nOnly user with correct access as admin can create new repository<br \/>\nIdentify the repository name and cluster. You must follow the approval process before creating any new repository.<br \/>\nCreate repository svnadmin create \/svnroot\/<Repo_name><br \/>\nchange the owner of repository to apache(if needed) chown -R apache:apache \/svnroot\/<Repo_name><br \/>\nNow you need to create Mirror repository on another SVN server, following are the steps to create &#8220;Mirror repository&#8221;.<\/p>\n<p>How to create Mirror Repository<br \/>\nTake the hotcopy of the repository from 1st SVN server.<br \/>\nsvnadmin hotcopy \/svnroot\/<Repo_name> \/tmp\/<Repo_name><br \/>\nRemove the hook script if any<br \/>\ncreate a tar file of the repo and scp it to 2nd SVN server.<br \/>\nLog in to 2nd server and untar the file.<br \/>\nnow again do hotcopy to svnroot location on 2nd server<br \/>\nsvnadmin hotcopy <Repo_name> \/svnroot\/<Repo_name><\/p>\n<p>Create 2 hook scripts start-commit and pre-revprop-change on 2st servver, The reason for this is that you can make use of these script to make sure that commit to 2nd server is happening via automated way instead of someone manually committing which you do not want to happen.<br \/>\nChange the owner of repository to apache(if needed) chown -R apache:apache \/svnroot\/<Repo_name><br \/>\nNow you need to initialize the sync mechanism, login to 1st server.<br \/>\nGo to repository hook location and add following content in post-commit script.<br \/>\n#Calling sync job<br \/>\nTO=<SVN- Server URL>\/<repo_name>\/<br \/>\n\/svnroot\/hook-scripts\/sync.sh &#8220;$REPOS&#8221; &#8220;$TO&#8221; &#8220;2>&#038;1 > \/dev\/null &#038;<\/p>\n<p>The Above will run after every commit and sync the latest revision to mirror.<\/p>\n<p>Lets assume your main SVN repo is <SVN- Server URL>= svn.domain.com<br \/>\nAnd mirror SVN repo is <SVN-Mirror - Server URL>= svn-mirror.domain.com <\/p>\n<p>content of sync.sh<\/p>\n<p>#!\/bin\/bash<\/p>\n<p>REPOS=$1<br \/>\nMIRROR=$2<\/p>\n<p>#Replace your username and password<br \/>\nSVNSYNC=\/usr\/local\/bin\/svnsync<br \/>\nSYNC_USER=bot<br \/>\nSYNC_PASS=admin<br \/>\nSOURCE_USER=bot<br \/>\nSOURCE_PASS=admin<\/p>\n<p># Sync to Mirror<br \/>\n$SVNSYNC &#8211;non-interactive sync $MIRROR \\<br \/>\n&#8211;sync-username $SYNC_USER &#8211;sync-password $SYNC_PASS \\<br \/>\n&#8211;source-username $SOURCE_USER &#8211;source-password $SOURCE_PASS<br \/>\nif [ $? != 0 ]; then<br \/>\nmail -s &#8220;svn sync failed for $REPOS for $MIRROR&#8221; your-emain-id@my.com < \/dev\/null\nfi\n\ncreate a post-revprop-change script and add above content with following change\nTO=<SVN-Mirror - Server URL>\/<repo_name>\/<br \/>\n\/svnroot\/hook-scripts\/sync_prop.sh &#8220;$REPOS&#8221; &#8220;$TO&#8221; 2>&#038;1 > \/dev\/null &#038;<\/p>\n<p>Content of sync_prop.sh<\/p>\n<p>#!\/bin\/bash<\/p>\n<p>REPOS=$1<br \/>\nMIRROR=$2<\/p>\n<p>SVNSYNC=\/usr\/local\/bin\/svnsync<br \/>\nSYNC_USER=bot<br \/>\nSYNC_PASS=admin<br \/>\nSOURCE_USER=bot<br \/>\nSOURCE_PASS=admin<\/p>\n<p># Sync to Mirror<br \/>\n$SVNSYNC &#8211;non-interactive copy-revprops $MIRROR \\<br \/>\n&#8211;sync-username $SYNC_USER &#8211;sync-password $SYNC_PASS \\<br \/>\n&#8211;source-username $SOURCE_USER &#8211;source-password $SOURCE_PASS<br \/>\nif [ $? != 0 ]; then<br \/>\nmail -s &#8220;svn sync_Prop failed for $REPOS for $MIRROR&#8221; yourname@my.com < \/dev\/null\nfi\n\nNow, you need to initialize the sync, run the following command on Main SVN server(1st one).\nsvnsync initialize <SVN-Mirror - Server URL>\/<Repo_name>\/ svn.corp.domain.com\/ <Repo_name>\/ &#8211;sync-username bot &#8211;sync-password admin &#8211;source-username bot &#8211;source-password admin<\/p>\n<p>How to debug the svn sync problem<\/p>\n<p>Usualy sync failed and we get the alert saying the sync is getting failed.<br \/>\nif you try to run the sync manualy it may throw following error.<\/p>\n<p>Failed to get lock on destination repos, currently held by &#8216;something:db33884a-d10f-11e1-924a-47b0d8d1042f&#8217;<br \/>\nThis means last sync couldn&#8217;t perform the whole action and lock is still hanging for the repo.<br \/>\nIn this case you log in to mirror server for which it is failing and run the following command<\/p>\n<p>svn propdel svn:sync-lock &#8211;revprop -r 0 <SVN-Mirror - Server URL>\/<reponame>\/<\/p>\n<p>This will clear the lock and output would be something like &#8220;property &#8216;svn:sync-lock&#8217; deleted from repository revision 0&#8221;.<\/p>\n<p>Then you can go and run the manual sync command and it should work now. \ud83d\ude42<\/p>\n<p>Reference &#8211; ><a href=\"http:\/\/www.scmtechblog.net\/2015\/07\/svn-mirror-f...ve-back-up-high.html\">www.scmtechblog.net\/2015\/07\/svn-mirror-f&#8230;ve-back-up-high.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>vishal_vsh1 created the topic: SVN mirror for Live back-up &#8211; High Availability SVN mirror for Live back-up &#8211; High Availability [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[393],"tags":[395],"class_list":["post-1741","post","type-post","status-publish","format-standard","hentry","category-svnsubversion-version-control-systems","tag-svn"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SVN mirror for Live back-up - High Availability - scmGalaxy<\/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:\/\/www.scmgalaxy.com\/tutorials\/svn-mirror-for-live-back-up-high-availability\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SVN mirror for Live back-up - High Availability - scmGalaxy\" \/>\n<meta property=\"og:description\" content=\"vishal_vsh1 created the topic: SVN mirror for Live back-up &#8211; High Availability SVN mirror for Live back-up &#8211; High Availability [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/svn-mirror-for-live-back-up-high-availability\/\" \/>\n<meta property=\"og:site_name\" content=\"scmGalaxy\" \/>\n<meta property=\"article:published_time\" content=\"2017-12-06T05:25:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-02-27T09:31:10+00:00\" \/>\n<meta name=\"author\" content=\"scmgalaxy K\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"scmgalaxy K\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/svn-mirror-for-live-back-up-high-availability\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/svn-mirror-for-live-back-up-high-availability\\\/\"},\"author\":{\"name\":\"scmgalaxy K\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/fc12ad190f540e79460243c81148d102\"},\"headline\":\"SVN mirror for Live back-up &#8211; High Availability\",\"datePublished\":\"2017-12-06T05:25:23+00:00\",\"dateModified\":\"2021-02-27T09:31:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/svn-mirror-for-live-back-up-high-availability\\\/\"},\"wordCount\":654,\"commentCount\":0,\"keywords\":[\"SVN\"],\"articleSection\":[\"SVN(Subversion)\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/svn-mirror-for-live-back-up-high-availability\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/svn-mirror-for-live-back-up-high-availability\\\/\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/svn-mirror-for-live-back-up-high-availability\\\/\",\"name\":\"SVN mirror for Live back-up - High Availability - scmGalaxy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\"},\"datePublished\":\"2017-12-06T05:25:23+00:00\",\"dateModified\":\"2021-02-27T09:31:10+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/fc12ad190f540e79460243c81148d102\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/svn-mirror-for-live-back-up-high-availability\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/svn-mirror-for-live-back-up-high-availability\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/svn-mirror-for-live-back-up-high-availability\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SVN mirror for Live back-up &#8211; High Availability\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\",\"name\":\"scmGalaxy\",\"description\":\"A Platform for Software Engineers\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/fc12ad190f540e79460243c81148d102\",\"name\":\"scmgalaxy K\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g\",\"caption\":\"scmgalaxy K\"},\"sameAs\":[\"http:\\\/\\\/www.DevOpsSchool.com\"],\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/author\\\/scmgalaxy\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SVN mirror for Live back-up - High Availability - scmGalaxy","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:\/\/www.scmgalaxy.com\/tutorials\/svn-mirror-for-live-back-up-high-availability\/","og_locale":"en_US","og_type":"article","og_title":"SVN mirror for Live back-up - High Availability - scmGalaxy","og_description":"vishal_vsh1 created the topic: SVN mirror for Live back-up &#8211; High Availability SVN mirror for Live back-up &#8211; High Availability [&hellip;]","og_url":"https:\/\/www.scmgalaxy.com\/tutorials\/svn-mirror-for-live-back-up-high-availability\/","og_site_name":"scmGalaxy","article_published_time":"2017-12-06T05:25:23+00:00","article_modified_time":"2021-02-27T09:31:10+00:00","author":"scmgalaxy K","twitter_card":"summary_large_image","twitter_misc":{"Written by":"scmgalaxy K","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/svn-mirror-for-live-back-up-high-availability\/#article","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/svn-mirror-for-live-back-up-high-availability\/"},"author":{"name":"scmgalaxy K","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/fc12ad190f540e79460243c81148d102"},"headline":"SVN mirror for Live back-up &#8211; High Availability","datePublished":"2017-12-06T05:25:23+00:00","dateModified":"2021-02-27T09:31:10+00:00","mainEntityOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/svn-mirror-for-live-back-up-high-availability\/"},"wordCount":654,"commentCount":0,"keywords":["SVN"],"articleSection":["SVN(Subversion)"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.scmgalaxy.com\/tutorials\/svn-mirror-for-live-back-up-high-availability\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/svn-mirror-for-live-back-up-high-availability\/","url":"https:\/\/www.scmgalaxy.com\/tutorials\/svn-mirror-for-live-back-up-high-availability\/","name":"SVN mirror for Live back-up - High Availability - scmGalaxy","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website"},"datePublished":"2017-12-06T05:25:23+00:00","dateModified":"2021-02-27T09:31:10+00:00","author":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/fc12ad190f540e79460243c81148d102"},"breadcrumb":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/svn-mirror-for-live-back-up-high-availability\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.scmgalaxy.com\/tutorials\/svn-mirror-for-live-back-up-high-availability\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/svn-mirror-for-live-back-up-high-availability\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.scmgalaxy.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"SVN mirror for Live back-up &#8211; High Availability"}]},{"@type":"WebSite","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website","url":"https:\/\/www.scmgalaxy.com\/tutorials\/","name":"scmGalaxy","description":"A Platform for Software Engineers","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.scmgalaxy.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/fc12ad190f540e79460243c81148d102","name":"scmgalaxy K","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g","caption":"scmgalaxy K"},"sameAs":["http:\/\/www.DevOpsSchool.com"],"url":"https:\/\/www.scmgalaxy.com\/tutorials\/author\/scmgalaxy\/"}]}},"_links":{"self":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/1741","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/comments?post=1741"}],"version-history":[{"count":1,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/1741\/revisions"}],"predecessor-version":[{"id":1742,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/1741\/revisions\/1742"}],"wp:attachment":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media?parent=1741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/categories?post=1741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/tags?post=1741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}