mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-30 20:56:39 +00:00
debug backup
This commit is contained in:
parent
a66ef79c3c
commit
2168fd51d8
|
@ -205,10 +205,16 @@ class ServiceManager(Service):
|
||||||
@classmethod
|
@classmethod
|
||||||
def stash_a_path(cls, p: str):
|
def stash_a_path(cls, p: str):
|
||||||
if path.isdir(p):
|
if path.isdir(p):
|
||||||
|
logging.warning(f"It is a folder")
|
||||||
rmtree(cls.stash_for(p), ignore_errors=True)
|
rmtree(cls.stash_for(p), ignore_errors=True)
|
||||||
|
logging.warning(f"Copying {p} to {cls.stash_for(p)}")
|
||||||
copytree(p, cls.stash_for(p))
|
copytree(p, cls.stash_for(p))
|
||||||
else:
|
else:
|
||||||
|
logging.warning(f"It is a file")
|
||||||
|
logging.warning(f"Copying {p} to {cls.stash_for(p)}")
|
||||||
copyfile(p, cls.stash_for(p))
|
copyfile(p, cls.stash_for(p))
|
||||||
|
# Assert the file is copied
|
||||||
|
assert path.isfile(cls.stash_for(p))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def retrieve_stashed_path(cls, p: str):
|
def retrieve_stashed_path(cls, p: str):
|
||||||
|
@ -223,11 +229,17 @@ class ServiceManager(Service):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def pre_backup(cls):
|
def pre_backup(cls):
|
||||||
|
logging.warning("Pre-backup")
|
||||||
tempdir = cls.dump_dir()
|
tempdir = cls.dump_dir()
|
||||||
|
logging.warning(f"Tempdir: {tempdir}")
|
||||||
rmtree(join(tempdir), ignore_errors=True)
|
rmtree(join(tempdir), ignore_errors=True)
|
||||||
makedirs(tempdir)
|
makedirs(tempdir)
|
||||||
|
|
||||||
|
# Assert the tempdir is empty
|
||||||
|
assert len(listdir(tempdir)) == 0
|
||||||
|
|
||||||
for p in [USERDATA_FILE, SECRETS_FILE, DKIM_DIR]:
|
for p in [USERDATA_FILE, SECRETS_FILE, DKIM_DIR]:
|
||||||
|
logging.warning(f"Stashing {p}")
|
||||||
cls.stash_a_path(p)
|
cls.stash_a_path(p)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Loading…
Reference in a new issue