========
Backups
========

As with any important information technology system, Bonded Internet
data should be backed up on a regular basis. This document describes
backup capabilities and procedures.

Core Bonded Internet data
--------------------------

Core data about the Bonded Internet environment includes:

-  SQL database contents—this contains most of the data shown in the
   web interface, such as aggregators, bonds, legs, speed tests, and
   users.
-  Private certificate authority (CA)- this includes the CA key/cert and
   list of issued certificates.
-  Configuration information for applications running on the management
   server.

Historical performance metrics, used to generate the charts for bonders
and aggregators, are not considered core data. For information on how to
back up this data, see the "Performance metrics data" section below.

Backup downloads
+++++++++++++++++

You can download a Zip file of the most recent daily backup from the
backups administration page.

Backup location
++++++++++++++++

Core data is backed up to ``/var/lib/bondingadmin/backups/``.

Backups are performed nightly and old backup files are removed after
seven days. One week of backups for a partner with about 100 bonds takes
150-200 MB.

Offsite backups
++++++++++++++++

Partners should back up core data to a remote location no less
frequently than once a day. This prevents a storage failure or
accidental backup removal from destroying the only backups. There are
two ways to perform offsite backups:

#. Copy the contents of the application backup folder to a remote
   server. Open-source tools that can perform network backups include
   scp, rsync, `Duplicity <http://duplicity.nongnu.org/>`__,
   `rdiff-backup <http://www.nongnu.org/rdiff-backup/>`__, and
   `BackupPC <http://backuppc.sourceforge.net/>`__. Many proprietary
   solutions are also available.
#. For virtual management servers, you can use your normal
   outside-the-guest VM backup methods. If you back up guest images, the
   management server image will contain the application backup directory
   and can be used to restore to a new host.

Offsite backups
^^^^^^^^^^^^^^^^

As a service, the Bonded Internet vendor provides a nightly offsite
backup for most partners' core data. In general, we download your most
recent backup files within 24 hours of the local backup time. However,
please consider that we provide no guarantees about this service, and
all partners may not be included. Performance metrics are not backed up
for any partners.

To confirm if your management server is being backed up by the Bonded
Internet vendor's offsite server, or to disable this service, please
`submit a support ticket <../spaces/technical-support.html>`__.

Performance metrics data
-------------------------

Bonded Internet management servers collect detailed performance metrics
for every bonder, aggregator, and private WAN router, as well as the
management server itself. This data is valuable for detecting and
determining the cause of performance issues. However, the dataset can
become quite large over time and is excluded from the core data backups.

There are two databases containing performance data. The ``bonding``
database contains performance data for bonders, aggregators, and private
WAN routers and the ``bondingadmin`` database contains performance data
for the management server.

Backing up
+++++++++++

To perform a backup of the data in the ``bonding`` ``database``, for
example, execute the following command on the management server:

.. code::

    influxd backup -database bonding /tmp/influx-bonding

This will create a directory called ``/tmp/influx-bonding`` containing
the data. Standard file transfer tools such as ``rsync`` or ``scp`` can
be used to transfer the data to an offsite location.

Restoring
++++++++++

To perform a restore of the backup data for the ``bonding`` database,
copy the directory to the management server and execute the following
commands, assuming the files were placed in ``/tmp/influx-bonding``:

.. code::

    systemctl stop influxdb
    influxd restore -datadir /var/lib/influxdb/data/ -database bonding /tmp/influx-bonding
    systemctl start influxdb

This will load the backup data into the database.
