备份工具,svn的有效补充,不用扩建分支了
2009-01-15 16:09
197 查看
#!/usr/bin/env python
import shutil,os,time,sys,commands,string
def getbaks(name):
res = commands.getoutput('find %s -name revert'%bakpath)
destpath = os.path.abspath(sys.argv[2])
lst=[]
for revf in res.split():
for ln in file(revf):
cmdlines = ln.split()
if len(cmdlines)==4 and cmdlines[0]=='cp' and cmdlines[3][1:-1] == destpath:
lst.append([os.stat(cmdlines[2][1:-1])[8], (cmdlines[2][1:-1]), (cmdlines[3][1:-1])])
lst.sort()
lst.reverse()
return lst
bakpath = '~/baks'
bakpath = os.path.expanduser(bakpath)
if not os.path.exists(bakpath) :
os.mkdir(bakpath)
if len(sys.argv)==3:
if(sys.argv[1] == '-r'):
lst = getbaks(sys.argv[2])
ind = 1
for ln in lst:
print '[%d]'%ind , time.strftime("%m-%d %H:%M:%S", time.localtime(ln[0]))
ind += 1
ind = string.atoi(raw_input('select:'))
if ind>0 and len(lst)>=ind:
print lst[ind-1][1], "==>", lst[ind-1][2]
if os.path.isdir(lst[ind-1][2]):shutil.copytree(lst[ind-1][1], lst[ind-1][2])
else: shutil.copy(lst[ind-1][1], lst[ind-1][2])
exit(0)
if(sys.argv[1] == '-d'):
lst = getbaks(sys.argv[2])
for ln in lst:
os.system('meld %s %s'%(ln[1], ln[2]))
exit(0)
tmdir = "%s/%s"%(bakpath, time.strftime("%m%d", time.gmtime()))
if os.path.exists(tmdir) :
extdir = 1
while os.path.exists("%s-%d"%(tmdir, extdir)) :
extdir = extdir + 1
tmdir = "%s-%d"%(tmdir, extdir)
os.mkdir(tmdir)
f = file(("%s/%s")%(tmdir, 'revert'),'w')
for it in sys.argv[1:]:
des = "%s/%s"%(tmdir,os.path.basename(it))
c = 1
while os.path.exists(des):
des = "%s/%d-%s"%(tmdir,c,os.path.basename(it))
c = c+1
if(os.path.isdir(it)): shutil.copytree(it, des)
else: shutil.copyfile(it, des)
f.write('echo %s ==> %s/n'%(des, os.path.abspath(it)))
f.write('cp -rf "%s" "%s"/n'%(des, os.path.abspath(it)))
import shutil,os,time,sys,commands,string
def getbaks(name):
res = commands.getoutput('find %s -name revert'%bakpath)
destpath = os.path.abspath(sys.argv[2])
lst=[]
for revf in res.split():
for ln in file(revf):
cmdlines = ln.split()
if len(cmdlines)==4 and cmdlines[0]=='cp' and cmdlines[3][1:-1] == destpath:
lst.append([os.stat(cmdlines[2][1:-1])[8], (cmdlines[2][1:-1]), (cmdlines[3][1:-1])])
lst.sort()
lst.reverse()
return lst
bakpath = '~/baks'
bakpath = os.path.expanduser(bakpath)
if not os.path.exists(bakpath) :
os.mkdir(bakpath)
if len(sys.argv)==3:
if(sys.argv[1] == '-r'):
lst = getbaks(sys.argv[2])
ind = 1
for ln in lst:
print '[%d]'%ind , time.strftime("%m-%d %H:%M:%S", time.localtime(ln[0]))
ind += 1
ind = string.atoi(raw_input('select:'))
if ind>0 and len(lst)>=ind:
print lst[ind-1][1], "==>", lst[ind-1][2]
if os.path.isdir(lst[ind-1][2]):shutil.copytree(lst[ind-1][1], lst[ind-1][2])
else: shutil.copy(lst[ind-1][1], lst[ind-1][2])
exit(0)
if(sys.argv[1] == '-d'):
lst = getbaks(sys.argv[2])
for ln in lst:
os.system('meld %s %s'%(ln[1], ln[2]))
exit(0)
tmdir = "%s/%s"%(bakpath, time.strftime("%m%d", time.gmtime()))
if os.path.exists(tmdir) :
extdir = 1
while os.path.exists("%s-%d"%(tmdir, extdir)) :
extdir = extdir + 1
tmdir = "%s-%d"%(tmdir, extdir)
os.mkdir(tmdir)
f = file(("%s/%s")%(tmdir, 'revert'),'w')
for it in sys.argv[1:]:
des = "%s/%s"%(tmdir,os.path.basename(it))
c = 1
while os.path.exists(des):
des = "%s/%d-%s"%(tmdir,c,os.path.basename(it))
c = c+1
if(os.path.isdir(it)): shutil.copytree(it, des)
else: shutil.copyfile(it, des)
f.write('echo %s ==> %s/n'%(des, os.path.abspath(it)))
f.write('cp -rf "%s" "%s"/n'%(des, os.path.abspath(it)))
相关文章推荐
- SVN管理工具Cornerstone之:创建分支、提交合并
- svnadmin dump备份工具(转载)
- SVN之初恋与小三Meld优秀分支合并工具
- svnadmin dump备份工具
- 乌龟 svn工具建分支
- 04-Git版本备份/分支管理(补充了解)
- SVN之初恋与小三Meld优秀分支合并工具
- SVN管理工具Cornerstone之:创建分支
- svnadmin dump备份工具
- SVN管理工具Cornerstone之:创建分支、提交合并
- SVN管理工具Cornerstone之:创建分支、提交合并
- svnadmin dump备份工具
- Linux完整备份工具 - dump, restore(现在基本不用这两个)
- Eclipse工具svn分支合并功能
- Linux完整备份工具 - dump, restore(现在基本不用这两个)
- Svnsync:Subversion备份版本库的好工具
- 不用任何第三方工具,如何备份InnoDB?生产环境
- SVN管理工具Cornerstone之:创建分支、提交合并
- svnadmin dump备份工具(转载)