[wip] Work on borg local repo

This commit is contained in:
ljf 2019-01-01 16:42:48 +01:00
parent a7af79d93e
commit 9f5b826078
2 changed files with 128 additions and 106 deletions

View file

@ -1888,13 +1888,37 @@ class TarBackupMethod(BackupMethod):
class BorgBackupMethod(BackupMethod): class BorgBackupMethod(BackupMethod):
def __init__(self, repo=None):
super(TarBackupMethod, self).__init__(repo)
if not self.repo.domain:
filesystem.mkdir(self.repo.path, parent=True)
else:
#Todo Initialize remote repo
pass
@property @property
def method_name(self): def method_name(self):
return 'borg' return 'borg'
def backup(self): def backup(self):
""" Backup prepared files with borg """ """ Backup prepared files with borg """
super(CopyBackupMethod, self).backup() super(BorgBackupMethod, self).backup()
for path in self.manager.paths_to_backup:
source = path['source']
dest = os.path.join(self.repo.path, path['dest'])
if source == dest:
logger.debug("Files already copyed")
return
dest_parent = os.path.dirname(dest)
if not os.path.exists(dest_parent):
filesystem.mkdir(dest_parent, 0o750, True, uid='admin')
if os.path.isdir(source):
shutil.copytree(source, dest)
else:
shutil.copy(source, dest)
# TODO run borg create command # TODO run borg create command
raise YunohostError('backup_borg_not_implemented') raise YunohostError('backup_borg_not_implemented')

View file

@ -91,7 +91,7 @@ class BackupRepository(object):
except Exception as e: except Exception as e:
raise YunohostError('backup_cant_save_repositories_file', reason=e) raise YunohostError('backup_cant_save_repositories_file', reason=e)
def __init__(self, created=True, location, name=None, description=None, method=None, def __init__(self, created, location, name=None, description=None, method=None,
encryption=None, quota=None): encryption=None, quota=None):
self.location = location self.location = location
@ -151,7 +151,6 @@ class BackupRepository(object):
self.domain = location_match.group('domain') self.domain = location_match.group('domain')
self.path = location_match.group('path') self.path = location_match.group('path')
def backup_repository_list(name, full=False): def backup_repository_list(name, full=False):
""" """
List available repositories where put archives List available repositories where put archives
@ -163,7 +162,6 @@ class BackupRepository(object):
else: else:
return repositories.keys() return repositories.keys()
def backup_repository_info(name, human_readable=True, space_used=False): def backup_repository_info(name, human_readable=True, space_used=False):
""" """
Show info about a repository Show info about a repository