Commit 2934cbf6 authored by Tim Bleimehl's avatar Tim Bleimehl 🤸🏼
Browse files

wip

parent a81a1bde
......@@ -45,8 +45,8 @@ database_type_backupper_mapping: Dict[str, Type[BaseBackupper]] = {
default=False,
)
def cli(debug):
click.echo(f"Debug mode is {'on' if debug else 'off'}")
if debug:
click.echo(f"Debug mode is on")
log.setLevel("DEBUG")
......@@ -175,9 +175,14 @@ def k8s(namespace, all_namespaces):
bu.retention.rotate_existing_backups()
@cli.command()
@cli.group()
def docker():
pass
@docker.command()
@click.argument("target-dir", default="backup/")
def docker(target_dir):
def backup(target_dir):
"""Backup databases in a docker environment"""
for container_name in ContainerHelper.docker_get_container_to_be_backed_up():
......@@ -206,5 +211,22 @@ def docker(target_dir):
bu.retention.rotate_existing_backups()
@docker.command(name="restore")
def docker_restore():
print("RESTORE")
@cli.command()
@click.option(
"--mode",
default="docker",
prompt="How is your DB running?",
help="Environment the database is running in: 'Docker', 'k8s'",
type=click.Choice(["docker", "k8s"], case_sensitive=False),
)
def restore():
pass
if __name__ == "__main__":
cli()
......@@ -17,6 +17,8 @@ This means you only have to attach the right labels to your database containers
# Basic Example
### Setup
Lets create a mysql/mariadb database via docker-compose
```yaml
......@@ -26,6 +28,7 @@ services:
image: mariadb:10
ports:
- 3306:3306
container_name: mysql
environment:
- MYSQL_ROOT_PASSWORD=mysuperpw
restart: unless-stopped
......@@ -42,6 +45,19 @@ Start the DB:
`docker-compose up -d`
Lets write some data into our new database
```bash
docker exec mysql /usr/bin/mysql -N -h127.0.0.1 -uroot -pmysuperpw -e "\
CREATE DATABASE IF NOT EXISTS coda_test; \
CREATE TABLE IF NOT EXISTS coda_test.my_table(id INT AUTO_INCREMENT, firstname VARCHAR(32), PRIMARY KEY (id)); \
INSERT INTO coda_test.my_table(firstname) VALUES ('Anna'); \
INSERT INTO coda_test.my_table(firstname) VALUES ('Thomas'); \
"
```
### Backup
Now we can install CoDaBackup via
`pip3 install git+https://git.connect.dzd-ev.de/dzdtools/CoDaBackup -U`
......@@ -52,6 +68,7 @@ And lets backup our DB
Thats it. We now have a directory `./backups/` in front of us, with all databases backuped.
### Restore
# Features
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment