def bkDatabase(self, widgt, event): ''' 即时备份操作,需要用户输入保存到的容器名。 ''' self.statusbar.get_context_id('backInfo') self.statusbar.push(0, "备份数据库") print self.serInfo conndb = ConnDatabase(self.serInfo) connStor = ConnStorage(self.serInfo) (result, bakfilepath) = conndb.conn.bk_now() if result: dial = self.builder.get_object('dialogContainerName') conName = self.builder.get_object('entryContainer') self.response = dial.run() dial.hide() if conName.get_text() != '': connStor.upload_file(conName.get_text(), bakfilepath) self.statusbar.get_context_id('backInfo') self.statusbar.push(0, "数据库备份成功") else: self.statusbar.get_context_id('backInfo') self.statusbar.push(0, "未能获取指定的容器名") else: self.statusbar.get_context_id('backInfo') self.statusbar.push(0, "数据库备份失败") self.connStorage(widgt, event)
def incr_bak(self, serConf, bakcontainer): ''' 负责执行一次增量备份,将备份文件上传至云存储。 ''' conndb = ConnDatabase(serConf) connStor = ConnStorage(serConf) (result, bakfilepath) = conndb.conn.incr_bak() if result: connStor.upload_file(bakcontainer, bakfilepath) else: print 'increase backup error!'
def glob_bak(self, serConf, bakcontainer): ''' 负责执行一次全局备份,将备份文件上传至云存储。 ''' timestr = time.strftime(r"%Y-%m-%d_%H-%M-%S", time.localtime()) print timestr conndb = ConnDatabase(serConf) connStor = ConnStorage(serConf) (result, bakfilepath) = conndb.conn.glob_bak() if result: connStor.upload_file(bakcontainer, bakfilepath) else: print 'global backup error!'