canonical / juju-backup-all

Tool for backing up charms, local juju configs, and juju controllers.
Apache License 2.0
0 stars 5 forks source link
snap

Juju Backup All

Introduction

The juju-backup-all snap allows operators to streamline backing up their models in one go.

While various charms offer backup capabilities, it is up to the operator to determine which charms do so and how to invoke said capability. The juju-backup-all snap simplifies this down to a single command: juju-backup-all.

It currently supports backing up juju controllers, juju configs, and the following charms:

This snap enumerates through all controllers, backing up the controller and scanning through each model for any applications that can be backed up. It then saves these backups.

Find it on the Snap Store!

Get it from the Snap Store

Installation

Install juju-backup-all from Snap Store with:

snap install juju-backup-all

Then, make sure the appropriate interfaces are plugged:

snap connect juju-backup-all:juju-client-observe
snap connect juju-backup-all:ssh-keys

Usage

This tool primarily auto-discovers controllers/charms that need backing up. To backup the current controller, simply run:

juju-backup-all

This will backup all apps of all models (in the current controller) of supported charms and output them into juju-backups/ directory. It will also backup the local juju client config.

For a more complex command, here's an example that specifies an output directory, excludes certain charms, excludes the juju client config backup, and runs backups on all controllers.

juju-backup-all -o my/backups/ \
  -e postgresql \
  -e etcd \
  --all-controllers

If the charm cannot perform backup because the disk on the unit is full, or the default backup base directory is not writable for any reason. You can change the backup base directory for the unit. Directories will be created if needed.

Currently, the following applications are supported with the those default values.

juju-backup-all \
  --backup-location-on-postgresql "/home/ubuntu" \
  --backup-location-on-mysql "/var/backups/mysql" \
  --backup-location-on-etcd "/home/ubuntu/etcd-snapshots" \

The following command will give all the possible arguments that can be passed to the tool:

juju-backup-all -h

The backup directory structure will look like the following:

juju-backups/
├── local_configs/
│   └── juju.tar.gz
├── controller1/
│   ├── model1/
│   │   ├── mysql-innodb-cluster/
│          └── mysqldump.tar.gz
└── controller2/
    └── model1/
        └── etcd-app/
            └── backups.tar.gz

Development and Testing

To set up development environment:

make install-dev
. venv/bin/activate

# if pre-commit hooks desired:
pre-commit install

Functional tests

To run functional tests:

make functional

or

tox -e functional

Several environment variables are available for setting to help expedite testing. These include:

Unit tests

The unit tests run for two different versions of python - 3.6 (Ubuntu Bionic) and 3.8 (Ubuntu Focal), they will have to be available to run the unit tests.

To run unit tests:

make unittests

To run unit tests and also generate html coverage reports:

make unit-coverage

Building and Installing Snap Locally

To build the snap locally, simply run:

make snap

You can then install the locally built snap with:

sudo snap install --dangerous ./juju-backup-all_${VERSION}.snap

To clean up the snapcraft build environment, run the following:

make snap-clean