Tool to backup docker volumes
Project description
privateer
Table of Contents
Usage
privateer --version
privateer backup <path> --to=HOST [--exclude=TARGETS] [--include=TARGETS]
privateer restore <path> --from=HOST [--exclude=TARGETS] [--include=TARGETS] [--y]
privateer schedule <path> --to=HOST [--exclude=TARGETS] [--include=TARGETS]
privateer status
privateer cancel [--host=HOST]
Options:
--exclude=TARGETS Comma separated string of target names to exclude (default is to include all)
--include=TARGETS Comma separated string of target names to include (default is to include all)
--host=HOST Backup host to cancel scheduled backups for (default is to cancel all)
--y Restore without further prompting
<path>
is the path to a directory containing a privateer.json
file. This file should contain at least one target
and at least one host. See ./config/privateer.json
for an example. By default all targets in the config file are used,
but this can be overridden by explicitly including or excluding targets by name.
Manual backups
Backups can be run manually with privateer backup
. In this case the backup filename with be of the format:
<volume_name>-<machine_name>-%Y-%m-%dT%H-%M-%S.tar.gz
where machine_name
is the name of the soure machine.
Scheduling
Backups can be scheduled by specifying cron schedules in privateer.json
and running privateer schedule
.
In this case backup filenames will be of the format
<volume_name>-<schedule_name>-<machine_name>-%Y-%m-%dT%H-%M-%S.tar.gz
Backups can be scheduled to multiple hosts simultaneously by running privateer schedule
multiple times.
Cancelling backups
Cancel scheduled backups with privateer cancel
. By default this stops all scheduled backups, but if
multiple hosts are being backed up to, backups to a single host can be cancelled using the --host
option.
Restoring
Restoring is always a manual process, run with privateer restore
. By default it will prompt before restoring each
target, so that the user can inspect the filename that is being restored (to e.g. check that the backup being restored
has the expected machine name). To bypass prompting, pass the --y
option.
Note that the latest backup will always be restored (restoring from a specific date will be supported in a future release).
Status
privateer status
returns the status of all backups currently scheduled, in json format. E.g.
$ privateer status
2 hosts receiving backups:
{
"host": {
"name": "another_test",
"host_type": "local",
"path": "/home/aehill/Documents/dev/reside/privateer/another_starport"
},
"targets": [
{
"name": "another_volume",
"type": "volume",
"schedules": [
{
"name": "custom",
"schedule": "* * * * *",
"retention_days": 12
}
]
}
]
}
{
"host": {
"name": "test",
"host_type": "local",
"path": "/home/aehill/Documents/dev/reside/privateer/starport"
},
"targets": [
{
"name": "orderly_volume",
"type": "volume",
"schedules": [
{
"name": "daily",
"schedule": "0 2 * * *",
"retention_days": 7
}
]
}
]
}
Test and lint
hatch run test
hatch run lint:fmt
To get coverage reported locally in the console, use hatch run cov
.
On CI, use hatch run cov-ci
to generate an xml report.
Installation
pip install privateer
Install from local sources
hatch build
pip install dist/privateer-{version}.tar.gz
Publish to PyPi
Ensure you have built a new version of the package:
hatch clean
hatch build
Then publish to the test server:
hatch publish -r test
You will be prompted to enter your test.pypi.org username and password. To test the installation, first run Python in a container:
docker run --rm -it --entrypoint bash python
Then:
pip install --index-url https://test.pypi.org/simple privateer --extra-index-url https://pypi.org/simple
Now you should be able to run privateer
from the command line and see the usage instructions.
If it is working, you can publish to the real PyPi:
hatch publish
License
privateer
is distributed under the terms of the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for privateer-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbb22061767a54ec0b7da37365a1deec67c2eafca52e8790a128b5651cfab190 |
|
MD5 | dcda13162aea550496c185b0dfba05db |
|
BLAKE2b-256 | 85dbc4153d6a3c7c6f1b8df599bfd77cec3e63ecc3d8f4b3f0c711d44c974133 |