backup.py

changeset 71
a8a5ebb64e02
parent 70
3f794760d52e
child 74
4f56142e7497
equal deleted inserted replaced
70:3f794760d52e 71:a8a5ebb64e02
189 self.thread_res=None 189 self.thread_res=None
190 190
191 self.current_operation=None 191 self.current_operation=None
192 self.scheduled_operation=None 192 self.scheduled_operation=None
193 self.lastrun_when=None 193 self.lastrun_when=None
194 self.lastrun_finished=None
194 self.state=State.INACTIVE 195 self.state=State.INACTIVE
195 self.errors=Errors.OK 196 self.errors=Errors.OK
196 197
197 self.__decode_config(cfg) 198 self.__decode_config(cfg)
198 199
259 msg['message']='UNKNOWN' 260 msg['message']='UNKNOWN'
260 if 'name' not in msg: 261 if 'name' not in msg:
261 msg['name']='borg' 262 msg['name']='borg'
262 lvl=translate_loglevel(msg['levelname']) 263 lvl=translate_loglevel(msg['levelname'])
263 self.logger.log(lvl, msg['name'] + ': ' + msg['message']) 264 self.logger.log(lvl, msg['name'] + ': ' + msg['message'])
264 if lvl>=logging.ERROR 265 if lvl>=logging.ERROR:
265 errormsg=msg 266 errormsg=msg
266 errors=Errors.ERRORS 267 errors=Errors.ERRORS
267 if ('msgid' in msg and 268 if ('msgid' in msg and
268 (msg['msgid']=='LockTimeout' or # observed in reality 269 (msg['msgid']=='LockTimeout' or # observed in reality
269 msg['msgid']=='LockErrorT' or # in docs 270 msg['msgid']=='LockErrorT' or # in docs
383 self.logger.error('Borg subprocess did not terminate') 384 self.logger.error('Borg subprocess did not terminate')
384 self.errors=self.errors.combine(Errors.ERRORS) 385 self.errors=self.errors.combine(Errors.ERRORS)
385 386
386 if self.current_operation.operation=='create': 387 if self.current_operation.operation=='create':
387 self.lastrun_when=self.current_operation.when_monotonic 388 self.lastrun_when=self.current_operation.when_monotonic
389 self.lastrun_finished=time.monotonic()
388 self.thread_res=None 390 self.thread_res=None
389 self.thread_log=None 391 self.thread_log=None
390 self.borg_instance=None 392 self.borg_instance=None
391 self.current_operation=None 393 self.current_operation=None
392 self.state=State.INACTIVE 394 self.state=State.INACTIVE
472 self.__update_status() 474 self.__update_status()
473 475
474 def __next_operation_unlocked(self): 476 def __next_operation_unlocked(self):
475 # TODO: pruning as well 477 # TODO: pruning as well
476 now=time.monotonic() 478 now=time.monotonic()
477 if not self.lastrun_when: 479 if not self.lastrun_finished:
478 initial_interval=self.retry_interval 480 initial_interval=self.retry_interval
479 if initial_interval==0: 481 if initial_interval==0:
480 initial_interval=self.backup_interval 482 initial_interval=self.backup_interval
481 if initial_interval==0: 483 if initial_interval==0:
482 return None 484 return None
486 elif not self.errors.ok(): 488 elif not self.errors.ok():
487 if self.retry_interval==0: 489 if self.retry_interval==0:
488 return None 490 return None
489 else: 491 else:
490 return Operation(Operation.CREATE, 492 return Operation(Operation.CREATE,
491 self.lastrun_when+self.retry_interval, 493 self.lastrun_finished+self.retry_interval,
492 reason='retry') 494 reason='retry')
493 else: 495 else:
494 if self.backup_interval==0: 496 if self.backup_interval==0:
495 return None 497 return None
496 else: 498 else:

mercurial