mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-10-18 07:31:55 +00:00
backups: Run compact in cleanup
Tests: - Enable scheduled backups for root and remote repo. Modify schedule.py so that backups and cleanup will run every 2 minutes. Log shows compact command is run for both /var/lib/freedombox/borgbackup and mount location for remote repo. No errors shown in log. Closes: #2380 Signed-off-by: James Valleroy <jvalleroy@mailbox.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
b739a1e831
commit
27ff747cf0
@ -316,6 +316,12 @@ def delete_archive(path: str, encryption_passphrase: secret_str | None = None):
|
||||
_run(['borg', 'delete', path], encryption_passphrase)
|
||||
|
||||
|
||||
@privileged
|
||||
def compact(path: str):
|
||||
"""Compact segments and free repo disk space."""
|
||||
_run(['borg', 'compact', path])
|
||||
|
||||
|
||||
def _extract(archive_path, destination, encryption_passphrase, locations=None):
|
||||
"""Extract archive contents."""
|
||||
prev_dir = os.getcwd()
|
||||
|
||||
@ -81,9 +81,9 @@ class BaseBorgRepository(abc.ABC):
|
||||
def prepare():
|
||||
"""Prepare the repository for operations."""
|
||||
|
||||
@staticmethod
|
||||
def cleanup():
|
||||
def cleanup(self):
|
||||
"""Cleanup the repository after operations."""
|
||||
privileged.compact(self.borg_path)
|
||||
|
||||
def get_info(self):
|
||||
"""Return Borg information about a repository."""
|
||||
@ -317,6 +317,7 @@ class SshBorgRepository(BaseBorgRepository):
|
||||
|
||||
def cleanup(self):
|
||||
"""Cleanup the repository after operations by unmounting."""
|
||||
super().cleanup()
|
||||
self._umount_ignore_errors()
|
||||
|
||||
@property
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user