fix(backups): Do not shut down the service during backup
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
We do not want the user to expirience outages during automatic backups. Generally, they are not even needed. We should use hooks to service-specific tasks, such as creating the database dump, so we don't have to shut down Postgres.pull/35/head
parent
f4ac3d29a9
commit
2df448a4a9
|
@ -4,8 +4,10 @@ from typing import List, Optional
|
||||||
|
|
||||||
from selfprivacy_api.utils import ReadUserData, WriteUserData
|
from selfprivacy_api.utils import ReadUserData, WriteUserData
|
||||||
|
|
||||||
from selfprivacy_api.services import get_service_by_id
|
from selfprivacy_api.services import (
|
||||||
from selfprivacy_api.services import get_all_services
|
get_service_by_id,
|
||||||
|
get_all_services,
|
||||||
|
)
|
||||||
from selfprivacy_api.services.service import (
|
from selfprivacy_api.services.service import (
|
||||||
Service,
|
Service,
|
||||||
ServiceStatus,
|
ServiceStatus,
|
||||||
|
@ -210,15 +212,13 @@ class Backups:
|
||||||
Jobs.update(job, status=JobStatus.RUNNING)
|
Jobs.update(job, status=JobStatus.RUNNING)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with StoppedService(service):
|
service.pre_backup()
|
||||||
Backups.assert_dead(service) # to be extra sure
|
snapshot = Backups.provider().backupper.start_backup(
|
||||||
service.pre_backup()
|
folders,
|
||||||
snapshot = Backups.provider().backupper.start_backup(
|
tag,
|
||||||
folders,
|
)
|
||||||
tag,
|
Backups._store_last_snapshot(tag, snapshot)
|
||||||
)
|
service.post_restore()
|
||||||
Backups._store_last_snapshot(tag, snapshot)
|
|
||||||
service.post_restore()
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Jobs.update(job, status=JobStatus.ERROR)
|
Jobs.update(job, status=JobStatus.ERROR)
|
||||||
raise e
|
raise e
|
||||||
|
@ -489,9 +489,12 @@ class Backups:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def assert_dead(service: Service):
|
def assert_dead(service: Service):
|
||||||
# if we backup the service that is failing to restore it to the
|
"""
|
||||||
# previous snapshot, its status can be FAILED
|
|
||||||
# And obviously restoring a failed service is the main route
|
If we backup the service that is failing to restore it to the previous snapshot,
|
||||||
|
its status can be FAILED.
|
||||||
|
And obviously restoring a failed service is the main route
|
||||||
|
"""
|
||||||
if service.get_status() not in [
|
if service.get_status() not in [
|
||||||
ServiceStatus.INACTIVE,
|
ServiceStatus.INACTIVE,
|
||||||
ServiceStatus.FAILED,
|
ServiceStatus.FAILED,
|
||||||
|
|
Loading…
Reference in New Issue