doc: dev: Update documentation for using backup component

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa 2020-09-27 20:43:43 -07:00 committed by Veiko Aasa
parent fb1898befc
commit 5f3c691c38
No known key found for this signature in database
GPG Key ID: 478539CAE680674E
4 changed files with 54 additions and 31 deletions

View File

@ -0,0 +1,7 @@
.. SPDX-License-Identifier: CC-BY-SA-4.0
Backups
^^^^^^^
.. autoclass:: plinth.modules.backups.components.BackupRestore
:members:

View File

@ -15,6 +15,7 @@ Components
domain
letsencrypt
staticfiles
backups
Base Classes
^^^^^^^^^^^^

View File

@ -229,3 +229,49 @@ a later section of this tutorial. The next parameter specifies whether anonymous
users who are not logged into FreedomBox should be shown this shortcut. The
final parameter further restricts to which group of users this shortcut must be
shown.
Adding backup/restore functionality
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Each app in FreedomBox needs to provide the ability to backup and restore its
configuration and data. Apart from providing durability to users' data, this
allows the user to migrate from one machine to another. FreedomBox framework
provides a component for handling these operations. Create the
:class:`~plinth.modules.backups.components.BackupRestore` component during app
initialization.
In ``__init__.py``, add:
.. code-block:: python3
from plinth.modules.backups.components import BackupRestore
from . import manifest
class TransmissionApp(app_module.App):
...
def __init__(self):
...
backup_restore = BackupRestore('backup-restore-transmission',
**manifest.backup)
self.add(backup_restore)
In ``manifest.py``, add:
.. code-block:: python3
backup = {
'data': {
'directories': ['/var/lib/transmission-daemon/.config']
},
'secrets': {
'files': ['/etc/transmission-daemon/settings.json']
},
'services': ['transmission-daemon']
}
The data and secrets information specifies which list of files and directories
FreedomBox framework needs to backup and restore. The list of services specifies
which daemons should be stopped during the backup and restore process.

View File

@ -68,37 +68,6 @@ Then, in ``views.py``, add:
...
manual_page = transmission.manual_page
Adding backup/restore functionality
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Each app in FreedomBox needs to provide the ability to backup its configuration
and data. Apart from providing durability to users' data, this allows the user
to migrate from one machine to another. FreedomBox framework provides a simple
declarative mechanism to allow the app to be backed up and restored. In
``manifest.py``, add:
.. code-block:: python3
from plinth.modules.backups.api import validate as validate_backup
backup = validate_backup({
'data': {
'directories': ['/var/lib/transmission-daemon/.config']
},
'secrets': {
'files': ['/etc/transmission-daemon/settings.json']
},
'services': ['transmission-daemon']
})
The data and secrets information specifies which list of files and directories
FreedomBox framework needs to backup. The list of services specifies which
daemons should be stopped during the backup process. In ``__init__.py``, add:
.. code-block:: python3
from .manifest import backup
Creating diagnostics
^^^^^^^^^^^^^^^^^^^^