mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-30 12:46:39 +00:00
fix circular import
This commit is contained in:
parent
60bf187f58
commit
95056b44b5
|
@ -248,7 +248,7 @@ class Backups:
|
||||||
raise ValueError("cannot backup a non-backuppable service")
|
raise ValueError("cannot backup a non-backuppable service")
|
||||||
folders = service.get_folders()
|
folders = service.get_folders()
|
||||||
service_name = service.get_id()
|
service_name = service.get_id()
|
||||||
service.pre_backup()
|
service.pre_backup(job=job)
|
||||||
snapshot = Backups.provider().backupper.start_backup(
|
snapshot = Backups.provider().backupper.start_backup(
|
||||||
folders,
|
folders,
|
||||||
service_name,
|
service_name,
|
||||||
|
@ -258,7 +258,7 @@ class Backups:
|
||||||
Backups._on_new_snapshot_created(service_name, snapshot)
|
Backups._on_new_snapshot_created(service_name, snapshot)
|
||||||
if reason == BackupReason.AUTO:
|
if reason == BackupReason.AUTO:
|
||||||
Backups._prune_auto_snaps(service)
|
Backups._prune_auto_snaps(service)
|
||||||
service.post_backup()
|
service.post_backup(job=job)
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
Jobs.update(job, status=JobStatus.ERROR, error=str(error))
|
Jobs.update(job, status=JobStatus.ERROR, error=str(error))
|
||||||
raise error
|
raise error
|
||||||
|
@ -452,7 +452,7 @@ class Backups:
|
||||||
with StoppedService(service):
|
with StoppedService(service):
|
||||||
if not service.is_always_active():
|
if not service.is_always_active():
|
||||||
Backups.assert_dead(service)
|
Backups.assert_dead(service)
|
||||||
service.pre_restore()
|
service.pre_restore(job=job)
|
||||||
if strategy == RestoreStrategy.INPLACE:
|
if strategy == RestoreStrategy.INPLACE:
|
||||||
Backups._inplace_restore(service, snapshot, job)
|
Backups._inplace_restore(service, snapshot, job)
|
||||||
else: # verify_before_download is our default
|
else: # verify_before_download is our default
|
||||||
|
@ -465,7 +465,7 @@ class Backups:
|
||||||
service, snapshot.id, verify=True
|
service, snapshot.id, verify=True
|
||||||
)
|
)
|
||||||
|
|
||||||
service.post_restore()
|
service.post_restore(job=job)
|
||||||
Jobs.update(
|
Jobs.update(
|
||||||
job,
|
job,
|
||||||
status=JobStatus.RUNNING,
|
status=JobStatus.RUNNING,
|
||||||
|
|
|
@ -478,16 +478,16 @@ class Service(ABC):
|
||||||
group=group,
|
group=group,
|
||||||
)
|
)
|
||||||
|
|
||||||
def pre_backup(self):
|
def pre_backup(self, job: Job):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def post_backup(self):
|
def post_backup(self, job: Job):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def pre_restore(self):
|
def pre_restore(self, job: Job):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def post_restore(self):
|
def post_restore(self, job: Job):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,8 @@ from os import mkdir, rmdir
|
||||||
from pydantic import BaseModel, ConfigDict
|
from pydantic import BaseModel, ConfigDict
|
||||||
from pydantic.alias_generators import to_camel
|
from pydantic.alias_generators import to_camel
|
||||||
|
|
||||||
from selfprivacy_api.backup.jobs import get_backup_job
|
|
||||||
from selfprivacy_api.backup.postgres import PostgresDumper
|
from selfprivacy_api.backup.postgres import PostgresDumper
|
||||||
from selfprivacy_api.jobs import JobStatus, Jobs
|
from selfprivacy_api.jobs import Job, JobStatus, Jobs
|
||||||
from selfprivacy_api.models.services import ServiceDnsRecord, ServiceStatus
|
from selfprivacy_api.models.services import ServiceDnsRecord, ServiceStatus
|
||||||
from selfprivacy_api.services.flake_service_manager import FlakeServiceManager
|
from selfprivacy_api.services.flake_service_manager import FlakeServiceManager
|
||||||
from selfprivacy_api.services.generic_size_counter import get_storage_usage
|
from selfprivacy_api.services.generic_size_counter import get_storage_usage
|
||||||
|
@ -475,9 +474,8 @@ class TemplatedService(Service):
|
||||||
group=group,
|
group=group,
|
||||||
)
|
)
|
||||||
|
|
||||||
def pre_backup(self):
|
def pre_backup(self, job: Job):
|
||||||
if self.get_postgresql_databases():
|
if self.get_postgresql_databases():
|
||||||
job = get_backup_job(self)
|
|
||||||
# Create the folder for the database dumps
|
# Create the folder for the database dumps
|
||||||
db_dumps_folder = self._get_db_dumps_folder()
|
db_dumps_folder = self._get_db_dumps_folder()
|
||||||
if not exists(db_dumps_folder):
|
if not exists(db_dumps_folder):
|
||||||
|
@ -494,23 +492,22 @@ class TemplatedService(Service):
|
||||||
backup_file = join(db_dumps_folder, f"{db_name}.sql.gz")
|
backup_file = join(db_dumps_folder, f"{db_name}.sql.gz")
|
||||||
db_dumper.backup_database(backup_file)
|
db_dumper.backup_database(backup_file)
|
||||||
|
|
||||||
def post_backup(self):
|
def post_backup(self, job: Job):
|
||||||
if self.get_postgresql_databases():
|
if self.get_postgresql_databases():
|
||||||
# Remove the folder for the database dumps
|
# Remove the folder for the database dumps
|
||||||
db_dumps_folder = self._get_db_dumps_folder()
|
db_dumps_folder = self._get_db_dumps_folder()
|
||||||
if exists(db_dumps_folder):
|
if exists(db_dumps_folder):
|
||||||
rmdir(db_dumps_folder)
|
rmdir(db_dumps_folder)
|
||||||
|
|
||||||
def pre_restore(self):
|
def pre_restore(self, job: Job):
|
||||||
if self.get_postgresql_databases():
|
if self.get_postgresql_databases():
|
||||||
# Create the folder for the database dumps
|
# Create the folder for the database dumps
|
||||||
db_dumps_folder = self._get_db_dumps_folder()
|
db_dumps_folder = self._get_db_dumps_folder()
|
||||||
if not exists(db_dumps_folder):
|
if not exists(db_dumps_folder):
|
||||||
mkdir(db_dumps_folder)
|
mkdir(db_dumps_folder)
|
||||||
|
|
||||||
def post_restore(self):
|
def post_restore(self, job: Job):
|
||||||
if self.get_postgresql_databases():
|
if self.get_postgresql_databases():
|
||||||
job = get_backup_job(self)
|
|
||||||
# Recover the databases
|
# Recover the databases
|
||||||
db_dumps_folder = self._get_db_dumps_folder()
|
db_dumps_folder = self._get_db_dumps_folder()
|
||||||
for db_name in self.get_postgresql_databases():
|
for db_name in self.get_postgresql_databases():
|
||||||
|
|
Loading…
Reference in a new issue