def on_buttonRecover1_clicked(self, object, data=None): conndb = ConnDatabase(self.serInfo) connstor = ConnStorage(self.serInfo) if self.storInfo['objname'][0] is not None: if 'glob' in self.storInfo['objname'][0]: # 从全局备份恢复 connstor.download_object(self.storInfo['conname'][0], self.storInfo['objname'][0], conndb.conn.bkdir) conndb.conn.recover_glob(conndb.conn.bkdir + "/" + self.storInfo['objname'][0]) elif 'incr' in self.storInfo['objname'][0]: # 从增量备份恢复 timestop = float(connstor.head_object(self.storInfo['conname'][0], \ self.storInfo['objname'][0]).get('x-timestamp')) dict_tmp = {} objlist = connstor.getContainerList( self.storInfo['conname'][0]) for objname in objlist: if 'glob' in objname: # 首先查找时间最近的一次全局备份 timestamp = float(connstor.head_object(self.storInfo['conname'][0], \ objname).get('x-timestamp')) dict_tmp[timestamp] = objname glob_bakfile = max(dict_tmp.itervalues(), key=lambda k: k) glob_timestamp = dict_tmp.keys()[dict_tmp.values().index( glob_bakfile)] dict_tmp.clear() for objname in objlist: if 'incr' in objname: # 然后查找该全局备份后所有的增量备份,到选中的增量备份为止 timestamp = float(connstor.head_object(self.storInfo['conname'][0], \ objname).get('x-timestamp')) if timestamp >= glob_timestamp and timestamp <= timestop: dict_tmp[timestamp] = objname # timestamp_list = sorted(dict_tmp.iterkeys(), key=lambda k:k[0]) # incr_bakfile_list = [] # for item in timestamp_list: # incr_bakfile_list.append(timestamp_list[item]) incr_bakfile_list = sorted(dict_tmp.itervaluse(), key=lambda k: k[0]) conndb.conn.recover_glob(glob_bakfile) conndb.conn.recover_incr(incr_bakfile_list) else: print 'Unkown backup file type!'
def on_buttonRecover1_clicked(self, object, data=None): conndb = ConnDatabase(self.serInfo) connstor = ConnStorage(self.serInfo) if self.storInfo['objname'][0] is not None: if 'glob' in self.storInfo['objname'][0]: # 从全局备份恢复 connstor.download_object(self.storInfo['conname'][0], self.storInfo['objname'][0], conndb.conn.bkdir) conndb.conn.recover_glob(conndb.conn.bkdir + "/" + self.storInfo['objname'][0]) elif 'incr' in self.storInfo['objname'][0]: # 从增量备份恢复 timestop = float(connstor.head_object(self.storInfo['conname'][0], \ self.storInfo['objname'][0]).get('x-timestamp')) dict_tmp = {} objlist = connstor.getContainerList(self.storInfo['conname'][0]) for objname in objlist: if 'glob' in objname: # 首先查找时间最近的一次全局备份 timestamp = float(connstor.head_object(self.storInfo['conname'][0], \ objname).get('x-timestamp')) dict_tmp[timestamp] = objname glob_bakfile = max(dict_tmp.itervalues(), key = lambda k:k) glob_timestamp = dict_tmp.keys()[dict_tmp.values().index(glob_bakfile)] dict_tmp.clear() for objname in objlist: if 'incr' in objname: # 然后查找该全局备份后所有的增量备份,到选中的增量备份为止 timestamp = float(connstor.head_object(self.storInfo['conname'][0], \ objname).get('x-timestamp')) if timestamp >= glob_timestamp and timestamp <= timestop: dict_tmp[timestamp] = objname # timestamp_list = sorted(dict_tmp.iterkeys(), key=lambda k:k[0]) # incr_bakfile_list = [] # for item in timestamp_list: # incr_bakfile_list.append(timestamp_list[item]) incr_bakfile_list = sorted(dict_tmp.itervaluse(), key=lambda k:k[0]) conndb.conn.recover_glob(glob_bakfile) conndb.conn.recover_incr(incr_bakfile_list) else: print 'Unkown backup file type!'
def headStor(self, widgt, event): ''' 获取云存储容器或对象的详细信息 ''' print self.serInfo connStor = ConnStorage(self.serInfo) if self.storInfo['objname'] is None: info = connStor.head_container(self.storInfo['conname']) else: info = connStor.head_object(self.storInfo['conname'], self.storInfo['objname']) info_str = " " for key, value in info.items(): info_str += key + " : " + str(value) + "\n" self.warnDial.set_markup(info_str) self.response = self.warnDial.run() self.warnDial.hide()