Metadata-Version: 2.5
Name: trytond_strings_xo_backup
Version: 8.0.0.1
Summary: Xen Orchestra Backup
Author: Clemens Hupka
Maintainer-email: Clemens Hupka <clemens.hupka@backend.at>
License-Expression: GPL-3.0-or-later
License-File: COPYRIGHT
License-File: LICENSE
Keywords: backup,orchestra,tryton,virtualization,xcp-ng,xen
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Environment :: Plugins
Classifier: Framework :: Tryton
Classifier: Topic :: Office/Business
Classifier: Topic :: System :: Systems Administration
Requires-Python: >=3.10
Requires-Dist: trytond-company<8.1,>=8.0
Requires-Dist: trytond-strings-xo-compute<8.1,>=8.0
Requires-Dist: trytond-strings-xo<8.1,>=8.0
Requires-Dist: trytond<8.1,>=8.0
Provides-Extra: test
Description-Content-Type: text/x-rst

Xen Orchestra Backups
=====================

The ``strings_xo_backup`` module manages the backups of the virtual
machines mirrored by ``strings_xo_compute`` through the Backup NG
feature of Xen Orchestra.  Xen Orchestra remains the authority on the
backups: the module mirrors the backup repositories, the backup jobs and
their schedules into Tryton, from which they are authored, and triggers
the runs, which are followed as ``xo.task`` records.  A backup is
therefore always executed by Xen Orchestra, and the retention policy
Tryton reports is the one Xen Orchestra enforces.

Backup remotes
--------------

A *backup remote*, a *repository* in the vocabulary of Xen Orchestra, is
the storage a job writes its backups to: an NFS, SMB or S3 share, or a
directory of the Xen Orchestra host.  The URL of a remote holds the
credentials of that storage; the module splits them out of the URL,
keeps them encrypted at rest with the credential store of ``strings_xo``
and masks them when they are read, so that a credential is never
readable in clear nor ever stored in clear.  A masked credential sent
back by a client is recognized as such and never overwrites the one
already stored.

The *Test* button checks that the storage is reachable, the *Health*
button stores the health Xen Orchestra reports, and the *Benchmark* and
*Forget* buttons start a bandwidth measure and the destruction of the
backups the remote holds, both of them followed as an ``xo.task``.
Forgetting the backups of a remote destroys data that cannot be
recovered, so the operation is confirmed by the user.

Backup jobs
-----------

A *Backup NG job* describes a backup: the machines it covers, the
remotes it writes to, whether it is a full or a delta backup, how the
backup is compressed and which proxy runs it.  Creating a job, or
reconfiguring its mode, its compression, its proxy or its selection,
writes it to Xen Orchestra through the JSON-RPC API, which is the only
API exposing the authoring of the three objects.

The whole job object is written, so that a write issued from Tryton
never drops a property Xen Orchestra holds under the object.  The raw
machine and remote selections are retained on the mirror, so that the
per-machine and per-remote settings of the backup, which the module does
not structure, are preserved by a write.  A machine selection expressed
as a smart pattern, by pool or by tag, names no machine the mirror can
resolve: it is reported as the *all* selection and kept in the pattern,
rather than flattened into the machines the pattern happens to match
when it is written.

*Run Now* starts a run of the job on Xen Orchestra and links the task
Xen Orchestra started it with, which is then followed until it reaches a
final state.

Backup schedules
----------------

A schedule says *when* the job it belongs to runs: it carries the cron
expression Xen Orchestra runs it by, the time zone the expression is
read in, and whether Xen Orchestra has it enabled.  A schedule always
belongs to a job, which is set when it is created and is not changed
afterwards.

Xen Orchestra remains the scheduler, so the scheduled action of the
module does not run the backups: it refreshes the mirrored repositories,
jobs and schedules, so that a backup is never started twice, once by Xen
Orchestra and once by Tryton.  A run can also be triggered at once from
the *Run Now* button of a schedule, which starts it in Xen Orchestra and
follows the task it was started with.

Retention policy
----------------

The retention policy of a schedule — the number of snapshots, exports
and copies kept, and the interval between two full backups — lives in
the settings of the job the schedule belongs to, keyed by the identifier
of the schedule.  The module mirrors that policy into read-only fields
of the schedule, read from the settings of the synchronised job, so that
the policy Tryton reports is the one Xen Orchestra enforces; the
settings themselves are the authority of Xen Orchestra and are never
written back.

Features
--------

- **Mirror**: the backup repositories, the Backup NG jobs and their
  schedules of every synchronised server are mirrored in Tryton,
  searchable and filterable; Xen Orchestra stays the authority and every
  operation is executed by it.
- **Authoring**: a remote, a job or a schedule is created, reconfigured
  and destroyed from Tryton, and the write is propagated to Xen
  Orchestra, while the writes issued by a synchronisation stay local.
- **Complete writes**: the object written is the complete object the
  mirror holds, so that a property the module does not structure is
  never dropped by a write issued from Tryton.
- **Encrypted credentials**: the credentials of a remote are encrypted
  at rest, masked in read results, and put back into the URL only when
  the remote is written to Xen Orchestra; a field-level access right
  keeps them out of the reach of a non-administrator.
- **Remote operations**: the test, the health, the benchmark and the
  forget operations Xen Orchestra exposes on a remote are offered as
  buttons, and the destructive one is confirmed by the user.
- **Runs as tasks**: a job and a schedule are run from Tryton, which
  starts the run in Xen Orchestra and mirrors the task it was started
  with, so that the run is followed to its final state.
- **Retention mirror**: the retention policy Xen Orchestra enforces for
  a schedule is reported by the schedule, as read from the settings of
  its job.
- **Ordered synchronisation**: the repositories are synchronised before
  the jobs referring to them and the jobs before their schedules, so
  that the relations between the three are resolved by the mirror
  itself.
- **Scheduled refresh**: a scheduled ``ir.cron`` refreshes the three
  collections, honouring the configuration and isolating the failure of
  a server from the others.
- **Security**: dedicated access groups, model access rights and
  permissions on the buttons restricting the operations to the
  administration groups.

Configuration
-------------

After installing the module, open *Xen Orchestra > Backups > Remotes* to
describe the storage the backups are written to, *Xen Orchestra >
Backups > Jobs* to describe the backups, and *Xen Orchestra > Backups >
Schedules* to describe when they run.  The remotes, the jobs and the
schedules are also listed on the *Backups* page of a Xen Orchestra
server, and the jobs covering a machine are listed on the *Backups* page
of a virtual machine.

The module reads the ``[strings_xo_backup]`` section of the trytond
configuration file:

.. code-block:: ini

    [strings_xo_backup]
    schedule_cron = True

``schedule_cron``
    whether the scheduled refresh of the backup mirror is enabled;
    defaults to ``True``.

The scheduled action ticks every 60 minutes and can be suspended by
deactivating its record in *Administration > Scheduled Actions*.
