mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] Add remote repo
This commit is contained in:
parent
c73a677d20
commit
ac0b4c4302
2 changed files with 25 additions and 3 deletions
|
@ -45,11 +45,15 @@ class BorgBackupRepository(LocalBackupRepository):
|
|||
|
||||
if self.domain:
|
||||
# TODO Use the best/good key
|
||||
private_key = "/root/.ssh/ssh_host_ed25519_key"
|
||||
private_key = "/etc/ssh/ssh_host_ed25519_key"
|
||||
|
||||
# Don't check ssh fingerprint strictly the first time
|
||||
# TODO improve this by publishing and checking this with DNS
|
||||
# FIXME known_host are hashed now
|
||||
try:
|
||||
strict = 'yes' if self.domain in open('/root/.ssh/known_hosts').read() else 'no'
|
||||
except FileNotFoundError:
|
||||
strict = 'no'
|
||||
env['BORG_RSH'] = "ssh -i %s -oStrictHostKeyChecking=%s"
|
||||
env['BORG_RSH'] = env['BORG_RSH'] % (private_key, strict)
|
||||
|
||||
|
@ -121,6 +125,8 @@ class BorgBackupRepository(LocalBackupRepository):
|
|||
|
||||
if "quota" in self.future_values and self.future_values["quota"]:
|
||||
cmd += ['--storage-quota', self.quota]
|
||||
|
||||
logger.debug(cmd)
|
||||
try:
|
||||
self._call('init', cmd)
|
||||
except YunohostError as e:
|
||||
|
@ -260,6 +266,7 @@ class BorgBackupArchive(BackupArchive):
|
|||
return HTTPResponse(reader, 200)
|
||||
|
||||
def extract(self, paths=[], destination=None, exclude_paths=[]):
|
||||
# TODO exclude_paths not available in actions map
|
||||
paths, destination, exclude_paths = super().extract(paths, destination, exclude_paths)
|
||||
cmd = ['borg', 'extract', self.archive_path] + paths
|
||||
for path in exclude_paths:
|
||||
|
|
|
@ -119,7 +119,10 @@ class BackupRepository(ConfigPanel):
|
|||
|
||||
self._load_current_values()
|
||||
|
||||
if self.__class__ == BackupRepository:
|
||||
self._cast_by_backup_method()
|
||||
|
||||
def _cast_by_backup_method(self):
|
||||
try:
|
||||
if self.method == 'tar':
|
||||
from yunohost.repositories.tar import TarBackupRepository
|
||||
self.__class__ = TarBackupRepository
|
||||
|
@ -129,6 +132,8 @@ class BackupRepository(ConfigPanel):
|
|||
else:
|
||||
from yunohost.repositories.hook import HookBackupRepository
|
||||
self.__class__ = HookBackupRepository
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
# =================================================
|
||||
# Config Panel Hooks
|
||||
|
@ -150,6 +155,16 @@ class BackupRepository(ConfigPanel):
|
|||
logger.debug("SHF running")
|
||||
return {'is_shf': True}
|
||||
|
||||
def post_ask__is_remote(self, question):
|
||||
if question.value:
|
||||
self.method = 'borg'
|
||||
self._cast_by_backup_method()
|
||||
return {}
|
||||
|
||||
def post_ask__method(self, question):
|
||||
self._cast_by_backup_method()
|
||||
return {}
|
||||
|
||||
# =================================================
|
||||
# Config Panel Override
|
||||
# =================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue