Add an offline backup/restore engine in `tools.backup`: - format based on XEP-0227 (pie), extended with Libervia sections - handle several data types (params, private, roster, pep , gpg, files and db) - per profile export/import and global handlers - a manifest is used to have metadata and checksums - full database snapshot/restore with the `db` type - sqla: add `get_db_url` - tools.common.utils: add `is_safe_relpath` and `is_process_running` rel 480
48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
|
|
# Libervia: an XMPP client
|
|
# Copyright (C) 2009-2026 Jérôme Poisson (goffi@goffi.org)
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class ProfileMeta(BaseModel):
|
|
"""Exported data of a profile."""
|
|
|
|
jid: str | None = Field(default=None, description="JabberID of the profile")
|
|
types: list[str] = Field(
|
|
default_factory=list, description="data types exported for this profile"
|
|
)
|
|
|
|
|
|
class Manifest(BaseModel):
|
|
"""Manifest of a backup archive (manifest.json)."""
|
|
|
|
format: str = Field(description="backup format name")
|
|
format_version: int = Field(description="backup format version")
|
|
app: str = Field(description="application that made the backup")
|
|
app_version: str = Field(description="version of the application")
|
|
alembic: str | None = Field(
|
|
default=None, description="database schema revision (None if unknown)"
|
|
)
|
|
date: str = Field(description="backup date (UTC, ISO 8601)")
|
|
profiles: dict[str, ProfileMeta] = Field(
|
|
default_factory=dict, description="exported profiles, by name"
|
|
)
|
|
files: dict[str, dict[str, str]] = Field(
|
|
default_factory=dict,
|
|
description="checksums of the archive entries, by entry name",
|
|
)
|