feature(backup): add migration specific endpoints

This commit is contained in:
Houkime 2024-07-24 11:21:37 +00:00
parent 8c44f78bbb
commit f6151ee451

View file

@ -26,6 +26,7 @@ from selfprivacy_api.backup.tasks import (
prune_autobackup_snapshots, prune_autobackup_snapshots,
) )
from selfprivacy_api.backup.jobs import add_backup_job, add_restore_job from selfprivacy_api.backup.jobs import add_backup_job, add_restore_job
from selfprivacy_api.backup.local_secret import LocalBackupSecret
@strawberry.input @strawberry.input
@ -40,6 +41,8 @@ class InitializeRepositoryInput:
# Key ID and key for Backblaze # Key ID and key for Backblaze
login: str login: str
password: str password: str
# For migration. If set, no new secret is generated
local_secret: typing.Optional[str]
@strawberry.type @strawberry.type
@ -63,6 +66,11 @@ class BackupMutations:
location=repository.location_name, location=repository.location_name,
repo_id=repository.location_id, repo_id=repository.location_id,
) )
secret = repository.local_secret
if secret is not None:
LocalBackupSecret.set(secret)
Backups.init_repo() Backups.init_repo()
return GenericBackupConfigReturn( return GenericBackupConfigReturn(
success=True, success=True,
@ -157,6 +165,14 @@ class BackupMutations:
job=job_to_api_job(job), job=job_to_api_job(job),
) )
@strawberry.mutation(permission_classes=[IsAuthenticated])
def restore_all(self):
"""
Restore all restorable and enabled services according to last autobackup snapshots
This happens in sync with partial merging of old configuration for compatibility
"""
pass
@strawberry.mutation(permission_classes=[IsAuthenticated]) @strawberry.mutation(permission_classes=[IsAuthenticated])
def restore_backup( def restore_backup(
self, self,