mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-07-29 12:09:37 +00:00
backups: repository: Introduce a prepare method
Useful for abstracting the mount() operation that is not available on non-remote repositories. - On non-remote repositories do nothing. - On remote repositories, mount the location in preparation for operations on the repository. Tests performed: - When an SSH repository is unmounted before a schedule backup, it is automatically mounted for listing, backup and cleanup at scheduled time. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
3789048854
commit
1170e438a3
@ -126,6 +126,10 @@ class BaseBorgRepository(abc.ABC):
|
||||
"""Return the repository that the backups action script should use."""
|
||||
return self._path
|
||||
|
||||
@staticmethod
|
||||
def prepare():
|
||||
"""Prepare the repository for operations."""
|
||||
|
||||
def get_info(self):
|
||||
"""Return Borg information about a repository."""
|
||||
output = self.run(['info', '--path', self.borg_path])
|
||||
@ -373,6 +377,13 @@ class SshBorgRepository(BaseBorgRepository):
|
||||
"""
|
||||
return self._mountpoint
|
||||
|
||||
def prepare(self):
|
||||
"""Prepare the repository for operations by mounting."""
|
||||
if not self.is_usable():
|
||||
raise errors.SshfsError('Remote host not verified')
|
||||
|
||||
self.mount()
|
||||
|
||||
@property
|
||||
def hostname(self):
|
||||
"""Return hostname from the remote path."""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user