mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-22 12:11:26 +00:00
feature(backups): stop services before restores
This commit is contained in:
parent
40ad1b5ce4
commit
b001e198bf
|
@ -258,16 +258,17 @@ class Backups:
|
|||
|
||||
try:
|
||||
Backups._assert_restorable(snapshot)
|
||||
with StoppedService(service):
|
||||
Backups.assert_dead(service)
|
||||
if strategy == RestoreStrategy.INPLACE:
|
||||
Backups._inplace_restore(service, snapshot, job)
|
||||
else: # verify_before_download is our default
|
||||
Jobs.update(job, status=JobStatus.RUNNING)
|
||||
Backups._restore_service_from_snapshot(
|
||||
service, snapshot.id, verify=True
|
||||
)
|
||||
|
||||
if strategy == RestoreStrategy.INPLACE:
|
||||
Backups._inplace_restore(service, snapshot, job)
|
||||
else: # verify_before_download is our default
|
||||
Jobs.update(job, status=JobStatus.RUNNING)
|
||||
Backups._restore_service_from_snapshot(
|
||||
service, snapshot.id, verify=True
|
||||
)
|
||||
|
||||
service.post_restore()
|
||||
service.post_restore()
|
||||
|
||||
except Exception as e:
|
||||
Jobs.update(job, status=JobStatus.ERROR)
|
||||
|
|
|
@ -379,7 +379,11 @@ def restore_strategy(request) -> RestoreStrategy:
|
|||
return RestoreStrategy.INPLACE
|
||||
|
||||
|
||||
def test_restore_snapshot_task(backups, dummy_service, restore_strategy):
|
||||
def test_restore_snapshot_task(
|
||||
backups, dummy_service, restore_strategy, simulated_service_stopping_delay
|
||||
):
|
||||
dummy_service.set_delay(simulated_service_stopping_delay)
|
||||
|
||||
Backups.back_up(dummy_service)
|
||||
snaps = Backups.get_snapshots(dummy_service)
|
||||
assert len(snaps) == 1
|
||||
|
|
Loading…
Reference in a new issue