-
-
Save feythin/4175551 to your computer and use it in GitHub Desktop.
git备份程序
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
''' | |
.ssh/config (windows,for local git server): | |
Host host100 | |
Hostname 192.168.1.100 | |
User git | |
IdentityFile C:/Users/admin/.ssh/id_rsa_gitBackup_host100 | |
repo example: | |
/home/git/test1.git | |
''' | |
hostName = "host100" | |
dirs = [ | |
'test1', | |
'test2' | |
] | |
for dirName in dirs: | |
print dirName," : ", | |
if os.path.exists(dirName): | |
strCmd = "cd %s && git pull && cd .." % dirName | |
os.system(strCmd) | |
else: | |
strCmd = "git clone %s:%s.git " % (hostName,dirName) | |
os.system(strCmd) | |
raw_input("Press Enter to continue") | |
''' | |
.ssh/config (windows,for github): | |
Host github | |
Hostname github.com | |
User git | |
IdentityFile C:/Users/admin/.ssh/id_rsa_github | |
Host gist | |
Hostname gist.github.com | |
User git | |
IdentityFile C:/Users/admin/.ssh/id_rsa_github_gist | |
Python code for github backup: | |
#for github | |
import os | |
hostName = "github" | |
userName = "mikezhang9986" | |
repoNames = [ | |
'cppCallLua', | |
'testCodes' | |
] | |
for repo in repoNames: | |
print repo," : ", | |
if os.path.exists(repo): | |
strCmd = "cd %s && git pull && cd .." % repo | |
os.system(strCmd) | |
else: | |
strCmd = "git clone %s:%s/%s.git " % (hostName,userName,repo) | |
os.system(strCmd) | |
Python code for gist backup: | |
#for gist | |
import os | |
hostName = "gist" | |
userName = "mikezhang9986" | |
repoNames = [ | |
'4166192', | |
'4084385' | |
] | |
for gist in repoNames: | |
print gist," : ", | |
if os.path.exists(gist): | |
strCmd = "cd %s && git pull && cd .." % gist | |
os.system(strCmd) | |
else: | |
strCmd = "git clone %s:%s.git " % (hostName,gist) | |
os.system(strCmd) | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment