feat: add LICENSE and README
This commit is contained in:
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 RamiusLr
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
102
README.md
Normal file
102
README.md
Normal file
@@ -0,0 +1,102 @@
|
||||
ddbb
|
||||
===
|
||||
|
||||
`ddbb`, for *Docker DataBase Backup*, is a tool to manage dumps of docker stacks
|
||||
databases.
|
||||
|
||||
The purpose isn't to manage full versionning, RPO, RTO, etc. I just want
|
||||
something simple to dump databases to a local file, that my backup tool would
|
||||
next handle.
|
||||
|
||||
This means this tool targets *Docker* databases only, and relies heavily on
|
||||
*Docker* API and labels.
|
||||
|
||||
|
||||
# Installation and prerequisites
|
||||
Use this `compose.yaml` as a base example:
|
||||
```yaml
|
||||
services:
|
||||
ddbb:
|
||||
image: ramiuslr/ddbb
|
||||
container_name: ddbb
|
||||
restart: always
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
- <your local dump directory>:/backups
|
||||
networks:
|
||||
- ddbb
|
||||
ports:
|
||||
- 3000:3000
|
||||
environment:
|
||||
BACKUP_CRON: "0 11,23 * * *"
|
||||
|
||||
networks:
|
||||
ddbb:
|
||||
name: ddbb
|
||||
```
|
||||
|
||||
The `BACKUP_CRON` variable is the cron variable format to schedule automatic databases
|
||||
dumps. You can check syntax on https://crontab.guru/.
|
||||
|
||||
Then you can run it with:
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
Please note that the container should have access to your databases networks,
|
||||
and the *Docker* socket.
|
||||
|
||||
You also need to declare your database credentials using variables, as show in
|
||||
the example below.
|
||||
|
||||
This tool has only been tested locally for now, and support only:
|
||||
- `mariadb`
|
||||
- `postgres`
|
||||
- `mongodb`
|
||||
|
||||
# Usage
|
||||
## Setting up the targets
|
||||
When you want to manage a database with `ddbb`, you just need to add two labels
|
||||
to its *Compose* manifest, for example:
|
||||
```yaml
|
||||
services:
|
||||
mariadb:
|
||||
image: mariadb:11.8.2
|
||||
container_name: mariadb
|
||||
restart: always
|
||||
expose:
|
||||
- 3306
|
||||
environment:
|
||||
MARIADB_RANDOM_ROOT_PASSWORD: true
|
||||
MARIADB_USER: <username>
|
||||
MARIADB_PASSWORD: <password>
|
||||
MARIADB_DATABASE: <database>
|
||||
volumes:
|
||||
- ./mariadb:/var/lib/mysql
|
||||
networks:
|
||||
- ddbb
|
||||
labels:
|
||||
ddbb.enable: true
|
||||
ddbb.kind: mariadb
|
||||
```
|
||||
The kind can be one of those:
|
||||
- `mariadb`
|
||||
- `postgres`
|
||||
- `mongodb`
|
||||
|
||||
The tool will then "see" your database and be able to connect to it, to perform
|
||||
the following actions:
|
||||
- Dump
|
||||
- Restore
|
||||
- Integrity check
|
||||
|
||||
# Building yourself
|
||||
There is a `Justfile` (*Makefile* alternative), which produces a *Docker* image, so this is pretty simple:
|
||||
```bash
|
||||
just run
|
||||
```
|
||||
|
||||
# Contributing
|
||||
Every suggestion, issue, or PR is very welcome !
|
||||
|
||||
However, please note that I am developing this on my spare time, so I can't
|
||||
guarantee response time, release dates, etc.
|
||||
@@ -152,14 +152,15 @@ func triggerRestore(c *gin.Context) {
|
||||
func triggerIntegrityCheck(c *gin.Context) {
|
||||
// Read Id from JSON submitted data
|
||||
var req RequestBody
|
||||
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request"})
|
||||
return
|
||||
}
|
||||
|
||||
if req.Id == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Missing backup job id"})
|
||||
}
|
||||
|
||||
if isValidJobId(req.Id) {
|
||||
result, err := integrity.NewIntegrityCheckJob(selectJob(req.Id))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user