-
-
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): | |
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): | |
print "exists" | |
strCmd = "cd %s && git pull && cd .." % dirName | |
print strCmd | |
os.system(strCmd) | |
else: | |
print "not exists" | |
strCmd = "git clone %s:%s.git " % (hostName,dirName) | |
os.system(strCmd) | |
raw_input("Press Enter to continue") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment