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

wip

parent c8e15966
......@@ -18,6 +18,9 @@ Maintainer: tim.bleimehl@dzd-ev.de
Status: Alpha (WIP - **do not use productive yet**)
[[_TOC_]]
# What is this (short)
CoDaBuddy helps you to automate setup and backup your database that is running in container environment (kubernetes, docker)
......@@ -26,8 +29,20 @@ It relies heavily on configuration by labels ([docker-labels](https://docs.docke
This means you only have to attach the right labels to your database containers and they will be ready to use and included in your daily backup.
# Features
* Supported Databases:
* Mysql
* Postgres
* Automatic backup retentation management (Daily, Weekly, Monthly, Yearly)
* "Backup now!" wizard
* Compressed backup
* Auto create databases and users
# Basic Example
## Docker example
### Setup
Lets create a mysql/mariadb database via docker-compose
......@@ -81,15 +96,104 @@ Thats it. We now have a directory `./backups/` in front of us, with all database
### Restore
# Features
* Supported Databases:
* Mysql
* Postgres
* Automatic backup retentation management (Daily, Weekly, Monthly, Yearly)
* "Backup now!" wizard
* Compressed backup
* Auto create databases and users
## Kubernetes example
### Setup
First we create a sample postgres database container
`postgres-deployment.yaml`
```yaml
apiVersion: v1
kind: Service
metadata:
name: postgres
spec:
ports:
- port: 5432
selector:
app: postgres
clusterIP: None
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
backup.dzd-ev.de/auto-create: true
backup.dzd-ev.de/enabled: true
backup.dzd-ev.de/password: supersavepw
backup.dzd-ev.de/type: postgres
backup.dzd-ev.de/username: postgres
annotations:
backup.dzd-ev.de/auto-create-databases: |-
[{
"database": "coda_ps_test",
"user": "coda_test",
"password": "super_save_pw"
}]
spec:
selector:
matchLabels:
workloadselector: postgres01
serviceName: ""
template:
metadata:
labels:
workloadselector: postgres01
spec:
containers:
- env:
- name: POSTGRES_PASSWORD
value: supersavepw
image: postgres:12
name: postgres01
ports:
- containerPort: 5432
hostPort: 5432
name: psport5432
```
`kubectl apply -f postgres-deployment.yaml`
### Setup Databases
We use the CoDaBuddy `auto-create`-feature to create our user and database
`auto-create kubernetes --all-namespaces`
### Backup
Now we create a CronJob for CoDaBuddy to create a daily backup
```yaml
apiVersion: batch/v1
kind: CronJob
metadata:
name: hello
spec:
schedule: "* * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- date; echo Hello from the Kubernetes cluster
restartPolicy: OnFailure
```
### What else..?
You can also define a kubernetes CronJob deployment to run your
# Planned features
......
......@@ -30,6 +30,7 @@ setup(
"console_scripts": [
"coda-backup=CoDaBuddy.cli:backup_cli",
"coda-restore=CoDaBuddy.cli:restore_cli",
"coda-auto-create=CoDaBuddy.cli:auto_create",
],
},
)
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