add: scrub
This commit is contained in:
@@ -29,8 +29,10 @@ def main():
|
|||||||
external_pool = ExternalPool.find_from_dict(config.backup_pools)
|
external_pool = ExternalPool.find_from_dict(config.backup_pools)
|
||||||
external_pool.import_()
|
external_pool.import_()
|
||||||
try:
|
try:
|
||||||
|
external_pool.scrub()
|
||||||
local_pool.backup_to(external_pool)
|
local_pool.backup_to(external_pool)
|
||||||
clean_old_snapshots(external_pool)
|
clean_old_snapshots(external_pool)
|
||||||
|
external_pool.scrub()
|
||||||
finally:
|
finally:
|
||||||
external_pool.export()
|
external_pool.export()
|
||||||
|
|
||||||
@@ -115,6 +117,12 @@ class ZFS:
|
|||||||
stdin=sender.stdout,
|
stdin=sender.stdout,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def scrub(pool: str, *, wait_for_finish=True) -> None:
|
||||||
|
run_command([config.ZPOOL, "scrub", pool])
|
||||||
|
if wait_for_finish:
|
||||||
|
run_command([config.ZPOOL, "wait", "-t", "scrub", pool])
|
||||||
|
|
||||||
|
|
||||||
class Disk:
|
class Disk:
|
||||||
def __init__(self, uuid: UUID, name: str):
|
def __init__(self, uuid: UUID, name: str):
|
||||||
@@ -211,6 +219,9 @@ class ExternalPool(Pool):
|
|||||||
def _export_pool(self) -> None:
|
def _export_pool(self) -> None:
|
||||||
ZFS.export_pool(self.name)
|
ZFS.export_pool(self.name)
|
||||||
|
|
||||||
|
def scrub(self) -> None:
|
||||||
|
ZFS.scrub(self.name)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def find_from_dict(cls, backup_pools: dict[str, UUID]) -> ExternalPool:
|
def find_from_dict(cls, backup_pools: dict[str, UUID]) -> ExternalPool:
|
||||||
present_uuids = [item.name for item in DISK_BY_UUID.iterdir()]
|
present_uuids = [item.name for item in DISK_BY_UUID.iterdir()]
|
||||||
|
|||||||
Reference in New Issue
Block a user