mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-03-13 02:04:09 +00:00
fix: API backups didn't backup userdata (#164)
Reviewed-on: https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api/pulls/164
This commit is contained in:
parent
a66ef79c3c
commit
8a672bab07
4 changed files with 15 additions and 5 deletions
selfprivacy_api
|
@ -258,6 +258,7 @@ class Backups:
|
|||
Backups._on_new_snapshot_created(service_name, snapshot)
|
||||
if reason == BackupReason.AUTO:
|
||||
Backups._prune_auto_snaps(service)
|
||||
service.post_backup()
|
||||
except Exception as error:
|
||||
Jobs.update(job, status=JobStatus.ERROR, error=str(error))
|
||||
raise error
|
||||
|
|
|
@ -150,7 +150,8 @@ class ServiceManager(Service):
|
|||
# Stash locations as they are set by user right now
|
||||
locations = {}
|
||||
for service in services:
|
||||
locations[service.get_id()] = service.get_drive()
|
||||
if service.is_movable():
|
||||
locations[service.get_id()] = service.get_drive()
|
||||
|
||||
# Copy files
|
||||
for p in [USERDATA_FILE, SECRETS_FILE, DKIM_DIR]:
|
||||
|
@ -158,9 +159,10 @@ class ServiceManager(Service):
|
|||
|
||||
# Pop locations
|
||||
for service in services:
|
||||
device = BlockDevices().get_block_device(locations[service.get_id()])
|
||||
if device is not None:
|
||||
service.set_location(device)
|
||||
if service.is_movable():
|
||||
device = BlockDevices().get_block_device(locations[service.get_id()])
|
||||
if device is not None:
|
||||
service.set_location(device)
|
||||
|
||||
@classmethod
|
||||
def stop(cls):
|
||||
|
@ -230,6 +232,10 @@ class ServiceManager(Service):
|
|||
for p in [USERDATA_FILE, SECRETS_FILE, DKIM_DIR]:
|
||||
cls.stash_a_path(p)
|
||||
|
||||
@classmethod
|
||||
def post_backup(cls):
|
||||
rmtree(cls.dump_dir(), ignore_errors=True)
|
||||
|
||||
@classmethod
|
||||
def dump_dir(cls) -> str:
|
||||
"""
|
||||
|
|
|
@ -480,6 +480,9 @@ class Service(ABC):
|
|||
def pre_backup(self):
|
||||
pass
|
||||
|
||||
def post_backup(self):
|
||||
pass
|
||||
|
||||
def post_restore(self):
|
||||
pass
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ from selfprivacy_api.utils.default_subdomains import (
|
|||
|
||||
USERDATA_FILE = "/etc/nixos/userdata.json"
|
||||
SECRETS_FILE = "/etc/selfprivacy/secrets.json"
|
||||
DKIM_DIR = "/var/dkim/"
|
||||
DKIM_DIR = "/var/dkim"
|
||||
|
||||
ACCOUNT_PATH_PATTERN = (
|
||||
"/var/lib/acme/.lego/accounts/*/acme-v02.api.letsencrypt.org/*/account.json"
|
||||
|
|
Loading…
Add table
Reference in a new issue