This Juju plugin allows operators to backup juju controllers as well as the following charms:
The plugin 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!
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
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
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
To set up development environment:
make install-dev
. venv/bin/activate
# if pre-commit hooks desired:
pre-commit install
To run functional tests:
make functional
or
tox -e functional
Several environment variables are available for setting to help expedite testing. These include:
PYTEST_KEEP_MODELS
: keeps the models after running functional tests. This helps in debugging and reuse of models for quicker testingPYTEST_MYSQL_MODEL
,PYTEST_ETCD_MODEL
: setting these to a current model will have the functional tests use that model instead of deploying another one.JUJU_DATA
: Specify where your juju client config directory is located. If not set, it will default to~/.local/share/juju
. This is needed in functional testing as the tool runs some subprocessjuju
commands (likejuju create-backup
) and without this set, the environment for functional tests has no info on controllers.PYTEST_SELECT_TESTS
: use to select tests based on their name (via pytest-k
expression docs)
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 unit
To run unit tests and also generate html coverage reports:
make unit-coverage
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