Skip to content

Commit

Permalink
Merge pull request #1 from jkaninda/develop
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
jkaninda authored Dec 19, 2023
2 parents e881408 + ecf8ae1 commit 53c6897
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
Binary file modified .DS_Store
Binary file not shown.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ bkup -o backup
```sh
bkup --operation backup --destination s3
```
## Docker run:

```sh
docker run --rm --network your_network_name --name mysql-bkup -v $PWD/backup:/backup/ -e "DB_HOST=database_host_name" -e "DB_USERNAME=username" -e "DB_PASSWORD=password" jkaninda/mysql-bkup:latest bkup -o backup -db database_name
```

## Docker compose file:
```yaml
version: '3'
services:
Expand Down Expand Up @@ -89,6 +95,15 @@ bkup -o restore -f database_20231217_115621.sql
```sh
bkup --operation restore --source s3 --file database_20231217_115621.sql
```

## Docker run:

```sh
docker run --rm --network your_network_name --name mysql-bkup -v $PWD/backup:/backup/ -e "DB_HOST=database_host_name" -e "DB_USERNAME=username" -e "DB_PASSWORD=password" jkaninda/mysql-bkup:latest bkup -o backup -db database_name -f napata_20231219_022941.sql.gz
```

## Docker compose file:

```yaml
version: '3'
services:
Expand Down Expand Up @@ -153,6 +168,32 @@ bkup --operation backup --destination s3 -database mydatabase
- S3_ENDPOINT=${S3_ENDPOINT}

```
## Run "docker run" from crontab

Make an automated backup (every night at 1).

> backup_script.sh
```sh
#!/bin/sh
DB_USERNAME='db_username'
DB_PASSWORD='password'
DB_HOST='db_hostname'
DB_NAME='db_name'
BACKUP_DIR='/some/path/backup/'

docker run --rm --name mysql-bkup -v $BACKUP_DIR:/backup/ -e "DB_HOST=$DB_HOST" -e "DB_USERNAME=$DB_USERNAME" -e "DB_PASSWORD=$DB_PASSWORD" jkaninda/mysql-bkup:latest bkup -o backup -db $DB_NAME
```

```sh
chmod +x backup_script.sh
```

Your crontab looks like this:

```conf
0 1 * * * /path/to/backup_script.sh
```

## Kubernetes CronJob

Expand Down
8 changes: 8 additions & 0 deletions backup_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
DB_USERNAME='db_username'
DB_PASSWORD='password'
DB_HOST='db_hostname'
DB_NAME='db_name'
BACKUP_DIR="$PWD/backup"

docker run --rm --name mysql-bkup -v $BACKUP_DIR:/backup/ -e "DB_HOST=$DB_HOST" -e "DB_USERNAME=$DB_USERNAME" -e "DB_PASSWORD=$DB_PASSWORD" jkaninda/mysql-bkup:latest bkup -o backup -db $DB_NAME

0 comments on commit 53c6897

Please sign in to comment.