Commits

Thejesh GN  committed 2833017

Update all your repos everyday.

  • Participants
  • Parent commits edb6856

Comments (0)

Files changed (1)

File maintanance/backup_hg_mercurial/fabfile.py

+################################################################
+# It uses fabfile to backup/update the mercurial databases
+# Ref: http://docs.fabfile.org/en/1.2.0/tutorial.html
+# Author : Thejesh GN [http://thejeshgn.com]
+# usage:
+#        cd to the build folder
+#        >fab help
+#        >fab daily
+#        >fab ship    
+################################################################
+from __future__ import with_statement
+from fabric.api import *
+from fabric.contrib.console import confirm
+from fabric.contrib import files 
+#env.user = 'root'
+#env.hosts = ['localhost']
+repos = ["data", "jaagteraho"]
+repo_folder='/home/thej/temp/'
+bitbucket_user ="janaagraha"
+def help():
+    print("Welcome to "+bitbucket_user+" mercurial repo backup.")
+    print("It simply updates all the given repositories for an user.")
+    print("You need to setup SSH access to your repository.")
+    print("Check https://bitbucket.org/account/")
+    print("Check https://bitbucket.org/help/UsingSSH/")
+    print("Try:")
+    print("$fab daily")
+    
+
+def daily(): 
+    print("++++++++  Welcome to "+bitbucket_user+" code backup +++++++++++") 
+    for repo in repos:
+        print "Updating the repository "+repo
+        with settings(warn_only=True):
+            result = local("cd "+repo_folder+repo, capture=True)
+        if result.failed:
+            print("Initial setup for the repo "+repo+". This is done only once.")
+            local("cd "+repo_folder)
+            local('hg clone ssh://hg@bitbucket.org/'+bitbucket_user+'/'+repo+' '+repo)      
+            local('hg update -C tip')
+        else:
+            print "Cool repo exists, I am going to update it."
+            local("cd "+repo_folder+repo)
+            local('hg pull')      
+            local('hg update -C tip')
+            print ("Done updating "+repo)
+    print("++++++++  Completed updating all"+bitbucket_user+" repositories +++++++++++")