Skip to content

Commit 4c44166

Browse files
authored
Merge pull request #113 from jkaninda/develop
Develop
2 parents dabba20 + 554df81 commit 4c44166

File tree

16 files changed

+657
-159
lines changed

16 files changed

+657
-159
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
uses: docker/build-push-action@v3
2626
with:
2727
push: true
28-
file: "./docker/Dockerfile"
28+
file: "./Dockerfile"
2929
platforms: linux/amd64,linux/arm64,linux/arm/v7
3030
build-args: |
3131
appVersion=develop-${{ github.sha }}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
uses: docker/build-push-action@v3
4040
with:
4141
push: true
42-
file: "./docker/Dockerfile"
42+
file: "./Dockerfile"
4343
platforms: linux/amd64,linux/arm64,linux/arm/v7
4444
build-args: |
4545
appVersion=${{ env.TAG_NAME }}

docker/Dockerfile renamed to Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ENV VERSION=${appVersion}
5252
LABEL author="Jonas Kaninda"
5353
LABEL version=${appVersion}
5454

55-
RUN apk --update add --no-cache mysql-client mariadb-connector-c gnupg tzdata
55+
RUN apk --update add --no-cache mysql-client mariadb-connector-c tzdata
5656
RUN mkdir $WORKDIR
5757
RUN mkdir $BACKUPDIR
5858
RUN mkdir -p $BACKUP_TMP_DIR

docs/how-tos/deprecated-configs.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: Update deprecated configurations
3+
layout: default
4+
parent: How Tos
5+
nav_order: 11
6+
---

docs/how-tos/encrypt-backup.md

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,39 @@
11
---
2-
title: Encrypt backups using GPG
2+
title: Encrypt backups
33
layout: default
44
parent: How Tos
55
nav_order: 8
66
---
77
# Encrypt backup
88

9-
The image supports encrypting backups using GPG out of the box. In case a `GPG_PASSPHRASE` environment variable is set, the backup archive will be encrypted using the given key and saved as a sql.gpg file instead or sql.gz.gpg.
9+
The image supports encrypting backups using one of two available methods: GPG with passphrase or GPG with a public key.
10+
11+
12+
The image supports encrypting backups using GPG out of the box. In case a `GPG_PASSPHRASE` or `GPG_PUBLIC_KEY` environment variable is set, the backup archive will be encrypted using the given key and saved as a sql.gpg file instead or sql.gz.gpg.
1013

1114
{: .warning }
12-
To restore an encrypted backup, you need to provide the same GPG passphrase or key used during backup process.
15+
To restore an encrypted backup, you need to provide the same GPG passphrase used during backup process.
1316

1417
- GPG home directory `/config/gnupg`
1518
- Cipher algorithm `aes256`
16-
-
17-
To decrypt manually, you need to install `gnupg`
1819

19-
### Decrypt backup
20+
{: .note }
21+
The backup encrypted using `GPG passphrase` method can be restored automatically, no need to decrypt it before restoration.
22+
Suppose you used a GPG public key during the backup process. In that case, you need to decrypt your backup before restoration because decryption using a `GPG private` key is not fully supported.
23+
24+
To decrypt manually, you need to install `gnupg`
2025

2126
```shell
2227
gpg --batch --passphrase "my-passphrase" \
2328
--output database_20240730_044201.sql.gz \
2429
--decrypt database_20240730_044201.sql.gz.gpg
2530
```
31+
Using your private key
2632

27-
### Backup
33+
```shell
34+
gpg --output database_20240730_044201.sql.gz --decrypt database_20240730_044201.sql.gz.gpg
35+
```
36+
## Using GPG passphrase
2837

2938
```yml
3039
services:
@@ -51,4 +60,32 @@ services:
5160
- web
5261
networks:
5362
web:
63+
```
64+
## Using GPG Public Key
65+
66+
```yml
67+
services:
68+
mysql-bkup:
69+
# In production, it is advised to lock your image tag to a proper
70+
# release version instead of using `latest`.
71+
# Check https://github.com/jkaninda/mysql-bkup/releases
72+
# for a list of available releases.
73+
image: jkaninda/mysql-bkup
74+
container_name: mysql-bkup
75+
command: backup -d database
76+
volumes:
77+
- ./backup:/backup
78+
environment:
79+
- DB_PORT=3306
80+
- DB_HOST=mysql
81+
- DB_NAME=database
82+
- DB_USERNAME=username
83+
- DB_PASSWORD=password
84+
## Required to encrypt backup
85+
- GPG_PUBLIC_KEY=/config/public_key.asc
86+
# mysql-bkup container must be connected to the same network with your database
87+
networks:
88+
- web
89+
networks:
90+
web:
5491
```

docs/how-tos/mutli-backup.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
title: Run multiple backup schedules in the same container
3+
layout: default
4+
parent: How Tos
5+
nav_order: 11
6+
---
7+
8+
Multiple backup schedules with different configuration can be configured by mounting a configuration file into `/config/config.yaml` `/config/config.yml` or by defining an environment variable `BACKUP_CONFIG_FILE=/backup/config.yaml`.
9+
10+
## Configuration file
11+
12+
```yaml
13+
#cronExpression: "@every 20m" //Optional for scheduled backups
14+
cronExpression: ""
15+
databases:
16+
- host: mysql1
17+
port: 3306
18+
name: database1
19+
user: database1
20+
password: password
21+
path: /s3-path/database1 #For SSH or FTP you need to define the full path (/home/toto/backup/)
22+
- host: mysql2
23+
port: 3306
24+
name: lldap
25+
user: lldap
26+
password: password
27+
path: /s3-path/lldap #For SSH or FTP you need to define the full path (/home/toto/backup/)
28+
- host: mysql3
29+
port: 3306
30+
name: keycloak
31+
user: keycloak
32+
password: password
33+
path: /s3-path/keycloak #For SSH or FTP you need to define the full path (/home/toto/backup/)
34+
- host: mysql4
35+
port: 3306
36+
name: joplin
37+
user: joplin
38+
password: password
39+
path: /s3-path/joplin #For SSH or FTP you need to define the full path (/home/toto/backup/)
40+
```
41+
## Docker compose file
42+
43+
```yaml
44+
services:
45+
mysql-bkup:
46+
# In production, it is advised to lock your image tag to a proper
47+
# release version instead of using `latest`.
48+
# Check https://github.com/jkaninda/mysql-bkup/releases
49+
# for a list of available releases.
50+
image: jkaninda/mysql-bkup
51+
container_name: mysql-bkup
52+
command: backup
53+
volumes:
54+
- ./backup:/backup
55+
environment:
56+
## Multi backup config file
57+
- BACKUP_CONFIG_FILE=/backup/config.yaml
58+
# mysql-bkup container must be connected to the same network with your database
59+
networks:
60+
- web
61+
networks:
62+
web:
63+
```

docs/reference/index.md

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -34,41 +34,42 @@ Backup, restore and migrate targets, schedule and retention are configured using
3434

3535
## Environment variables
3636

37-
| Name | Requirement | Description |
38-
|------------------------|---------------------------------------------------------------|------------------------------------------------------|
39-
| DB_PORT | Optional, default 3306 | Database port number |
40-
| DB_HOST | Required | Database host |
41-
| DB_NAME | Optional if it was provided from the -d flag | Database name |
42-
| DB_USERNAME | Required | Database user name |
43-
| DB_PASSWORD | Required | Database password |
44-
| AWS_ACCESS_KEY | Optional, required for S3 storage | AWS S3 Access Key |
45-
| AWS_SECRET_KEY | Optional, required for S3 storage | AWS S3 Secret Key |
46-
| AWS_BUCKET_NAME | Optional, required for S3 storage | AWS S3 Bucket Name |
47-
| AWS_BUCKET_NAME | Optional, required for S3 storage | AWS S3 Bucket Name |
48-
| AWS_REGION | Optional, required for S3 storage | AWS Region |
49-
| AWS_DISABLE_SSL | Optional, required for S3 storage | Disable SSL |
50-
| AWS_FORCE_PATH_STYLE | Optional, required for S3 storage | Force path style |
51-
| FILE_NAME | Optional if it was provided from the --file flag | Database file to restore (extensions: .sql, .sql.gz) |
52-
| GPG_PASSPHRASE | Optional, required to encrypt and restore backup | GPG passphrase |
53-
| BACKUP_CRON_EXPRESSION | Optional if it was provided from the `--cron-expression` flag | Backup cron expression for docker in scheduled mode |
54-
| SSH_HOST | Optional, required for SSH storage | ssh remote hostname or ip |
55-
| SSH_USER | Optional, required for SSH storage | ssh remote user |
56-
| SSH_PASSWORD | Optional, required for SSH storage | ssh remote user's password |
57-
| SSH_IDENTIFY_FILE | Optional, required for SSH storage | ssh remote user's private key |
58-
| SSH_PORT | Optional, required for SSH storage | ssh remote server port |
59-
| REMOTE_PATH | Optional, required for SSH or FTP storage | remote path (/home/toto/backup) |
60-
| FTP_HOST | Optional, required for FTP storage | FTP host name |
61-
| FTP_PORT | Optional, required for FTP storage | FTP server port number |
62-
| FTP_USER | Optional, required for FTP storage | FTP user |
63-
| FTP_PASSWORD | Optional, required for FTP storage | FTP user password |
64-
| TARGET_DB_HOST | Optional, required for database migration | Target database host |
65-
| TARGET_DB_PORT | Optional, required for database migration | Target database port |
66-
| TARGET_DB_NAME | Optional, required for database migration | Target database name |
67-
| TARGET_DB_USERNAME | Optional, required for database migration | Target database username |
68-
| TARGET_DB_PASSWORD | Optional, required for database migration | Target database password |
69-
| TG_TOKEN | Optional, required for Telegram notification | Telegram token (`BOT-ID:BOT-TOKEN`) |
70-
| TG_CHAT_ID | Optional, required for Telegram notification | Telegram Chat ID |
71-
| TZ | Optional | Time Zone |
37+
| Name | Requirement | Description |
38+
|------------------------|---------------------------------------------------------------|-----------------------------------------------------------------|
39+
| DB_PORT | Optional, default 3306 | Database port number |
40+
| DB_HOST | Required | Database host |
41+
| DB_NAME | Optional if it was provided from the -d flag | Database name |
42+
| DB_USERNAME | Required | Database user name |
43+
| DB_PASSWORD | Required | Database password |
44+
| AWS_ACCESS_KEY | Optional, required for S3 storage | AWS S3 Access Key |
45+
| AWS_SECRET_KEY | Optional, required for S3 storage | AWS S3 Secret Key |
46+
| AWS_BUCKET_NAME | Optional, required for S3 storage | AWS S3 Bucket Name |
47+
| AWS_BUCKET_NAME | Optional, required for S3 storage | AWS S3 Bucket Name |
48+
| AWS_REGION | Optional, required for S3 storage | AWS Region |
49+
| AWS_DISABLE_SSL | Optional, required for S3 storage | Disable SSL |
50+
| AWS_FORCE_PATH_STYLE | Optional, required for S3 storage | Force path style |
51+
| FILE_NAME | Optional if it was provided from the --file flag | Database file to restore (extensions: .sql, .sql.gz) |
52+
| GPG_PASSPHRASE | Optional, required to encrypt and restore backup | GPG passphrase |
53+
| GPG_PUBLIC_KEY | Optional, required to encrypt backup | GPG public key, used to encrypt backup (/config/public_key.asc) |
54+
| BACKUP_CRON_EXPRESSION | Optional if it was provided from the `--cron-expression` flag | Backup cron expression for docker in scheduled mode |
55+
| SSH_HOST | Optional, required for SSH storage | ssh remote hostname or ip |
56+
| SSH_USER | Optional, required for SSH storage | ssh remote user |
57+
| SSH_PASSWORD | Optional, required for SSH storage | ssh remote user's password |
58+
| SSH_IDENTIFY_FILE | Optional, required for SSH storage | ssh remote user's private key |
59+
| SSH_PORT | Optional, required for SSH storage | ssh remote server port |
60+
| REMOTE_PATH | Optional, required for SSH or FTP storage | remote path (/home/toto/backup) |
61+
| FTP_HOST | Optional, required for FTP storage | FTP host name |
62+
| FTP_PORT | Optional, required for FTP storage | FTP server port number |
63+
| FTP_USER | Optional, required for FTP storage | FTP user |
64+
| FTP_PASSWORD | Optional, required for FTP storage | FTP user password |
65+
| TARGET_DB_HOST | Optional, required for database migration | Target database host |
66+
| TARGET_DB_PORT | Optional, required for database migration | Target database port |
67+
| TARGET_DB_NAME | Optional, required for database migration | Target database name |
68+
| TARGET_DB_USERNAME | Optional, required for database migration | Target database username |
69+
| TARGET_DB_PASSWORD | Optional, required for database migration | Target database password |
70+
| TG_TOKEN | Optional, required for Telegram notification | Telegram token (`BOT-ID:BOT-TOKEN`) |
71+
| TG_CHAT_ID | Optional, required for Telegram notification | Telegram Chat ID |
72+
| TZ | Optional | Time Zone |
7273

7374
---
7475
## Run in Scheduled mode

go.mod

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,28 @@ go 1.22.5
55
require github.com/spf13/pflag v1.0.5
66

77
require (
8+
github.com/ProtonMail/gopenpgp/v2 v2.7.5
89
github.com/aws/aws-sdk-go v1.55.3
910
github.com/bramvdbogaerde/go-scp v1.5.0
1011
github.com/hpcloud/tail v1.0.0
12+
github.com/jlaffaye/ftp v0.2.0
13+
github.com/robfig/cron/v3 v3.0.1
1114
github.com/spf13/cobra v1.8.0
1215
golang.org/x/crypto v0.18.0
16+
gopkg.in/yaml.v3 v3.0.1
1317
)
1418

1519
require (
20+
github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect
21+
github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f // indirect
22+
github.com/cloudflare/circl v1.3.3 // indirect
1623
github.com/hashicorp/errwrap v1.1.0 // indirect
1724
github.com/hashicorp/go-multierror v1.1.1 // indirect
1825
github.com/inconshreveable/mousetrap v1.1.0 // indirect
19-
github.com/jlaffaye/ftp v0.2.0 // indirect
2026
github.com/jmespath/go-jmespath v0.4.0 // indirect
21-
github.com/robfig/cron/v3 v3.0.1 // indirect
27+
github.com/pkg/errors v0.9.1 // indirect
2228
golang.org/x/sys v0.22.0 // indirect
29+
golang.org/x/text v0.14.0 // indirect
2330
gopkg.in/fsnotify.v1 v1.4.7 // indirect
2431
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
2532
)

0 commit comments

Comments
 (0)