backup.py

changeset 20
fdfbe5d7b677
parent 17
5f6aa8830cea
child 21
c36e549a7f12
--- a/backup.py	Sat Jan 20 23:19:16 2018 +0000
+++ b/backup.py	Sat Jan 20 23:50:36 2018 +0000
@@ -5,6 +5,7 @@
 import config
 import logging
 import time
+import keyring
 from instance import BorgInstance
 from queue import Queue
 from threading import Thread, Lock, Timer
@@ -71,6 +72,15 @@
                                                          'Prune parameters', self.loc,
                                                          default=[])
 
+        keychain_account=config.check_string(cfg, 'keychain_account',
+                                             'Keychain account', self.loc,
+                                              default='')
+
+        if keychain_account and keychain_account!='':
+            pw=keyring.get_password("borg-backup", keychain_account)
+            self.__password=pw
+        else:
+            self.__password=None
 
     def __init__(self, identifier, cfg):
         self.identifier=identifier
@@ -212,7 +222,7 @@
 
     def __do_launch(self, queue, op, archive_or_repository, *args):
         inst=BorgInstance(op['operation'], archive_or_repository, *args)
-        inst.launch()
+        inst.launch(password=self.__password)
 
         t_log=Thread(target=self.__log_listener)
         t_log.daemon=True

mercurial