mirror of
https://github.com/jkaninda/mysql-bkup.git
synced 2026-11-13 16:47:14 +00:00
feat: mysql-bkup v2 on bkupkit
MysQL backup and restore built on the shared bkupkit core: streaming end to end, with no dump held in memory or written to local disk.
This commit is contained in:
1 parent
ccb3fcdf26
commit
28de0d7b52
65 files changed
+3453
-3871
No files matched your search
@@ -48,7 +48,7 @@ services:
|
||||
- DB_PORT=3306
|
||||
- DB_HOST=mysql
|
||||
- DB_NAME=database
|
||||
- DB_USERNAME=username
|
||||
- DB_USER=username
|
||||
- DB_PASSWORD=password
|
||||
## Azure Blob Configuration
|
||||
- AZURE_STORAGE_CONTAINER_NAME=backup-container
|
||||
|
||||
@@ -30,7 +30,7 @@ docker run --rm --network your_network_name \
|
||||
-v $PWD/backup:/backup/ \
|
||||
-e "DB_HOST=dbhost" \
|
||||
-e "DB_PORT=3306" \
|
||||
-e "DB_USERNAME=username" \
|
||||
-e "DB_USER=username" \
|
||||
-e "DB_PASSWORD=password" \
|
||||
jkaninda/mysql-bkup backup --all-databases
|
||||
```
|
||||
@@ -50,7 +50,7 @@ docker run --rm --network your_network_name \
|
||||
-v $PWD/backup:/backup/ \
|
||||
-e "DB_HOST=dbhost" \
|
||||
-e "DB_PORT=3306" \
|
||||
-e "DB_USERNAME=username" \
|
||||
-e "DB_USER=username" \
|
||||
-e "DB_PASSWORD=password" \
|
||||
jkaninda/mysql-bkup backup --all-in-one
|
||||
```
|
||||
|
||||
@@ -50,10 +50,10 @@ services:
|
||||
- DB_PORT=3306
|
||||
- DB_HOST=mysql
|
||||
- DB_NAME=database
|
||||
- DB_USERNAME=username
|
||||
- DB_USER=username
|
||||
- DB_PASSWORD=password
|
||||
## FTP Configuration
|
||||
- FTP_HOST="hostname"
|
||||
- FTP_HOST=hostname
|
||||
- FTP_PORT=21
|
||||
- FTP_USER=user
|
||||
- FTP_PASSWORD=password
|
||||
|
||||
@@ -42,14 +42,14 @@ services:
|
||||
# In production, lock your image tag to a specific release version
|
||||
# instead of using `latest`. Check https://github.com/jkaninda/pg-bkup/releases
|
||||
# for available releases.
|
||||
image: jkaninda/pg-bkup
|
||||
image: jkaninda/mysql-bkup
|
||||
container_name: pg-bkup
|
||||
command: backup --storage s3 -d database --path /my-custom-path
|
||||
environment:
|
||||
- DB_PORT=5432
|
||||
- DB_HOST=postgres
|
||||
- DB_NAME=database
|
||||
- DB_USERNAME=username
|
||||
- DB_USER=username
|
||||
- DB_PASSWORD=password
|
||||
## AWS Configuration
|
||||
- AWS_S3_ENDPOINT=https://s3.amazonaws.com
|
||||
@@ -58,7 +58,7 @@ services:
|
||||
- AWS_ACCESS_KEY=xxxx
|
||||
- AWS_SECRET_KEY=xxxxx
|
||||
## Optional: Disable SSL for S3 alternatives like Minio
|
||||
- AWS_DISABLE_SSL="false"
|
||||
- AWS_DISABLE_SSL=false
|
||||
## Optional: Enable path-style access for S3 alternatives like Minio
|
||||
- AWS_FORCE_PATH_STYLE=false
|
||||
|
||||
@@ -91,7 +91,7 @@ services:
|
||||
- DB_PORT=3306
|
||||
- DB_HOST=mysql
|
||||
- DB_NAME=database
|
||||
- DB_USERNAME=username
|
||||
- DB_USER=username
|
||||
- DB_PASSWORD=password
|
||||
## AWS Configuration
|
||||
- AWS_S3_ENDPOINT=https://s3.amazonaws.com
|
||||
@@ -104,11 +104,11 @@ services:
|
||||
## Optional: Delete old backups after a specified number of days
|
||||
#- BACKUP_RETENTION_DAYS=7
|
||||
## Optional: Disable SSL for S3 alternatives like Minio
|
||||
- AWS_DISABLE_SSL="false"
|
||||
- AWS_DISABLE_SSL=false
|
||||
## Optional: Enable path-style access for S3 alternatives like Minio
|
||||
- AWS_FORCE_PATH_STYLE=false
|
||||
|
||||
# Ensure the pg-bkup container is connected to the same network as your database
|
||||
# Ensure the mysql-bkup container is connected to the same network as your database
|
||||
networks:
|
||||
- web
|
||||
|
||||
@@ -122,5 +122,5 @@ networks:
|
||||
|
||||
- **Cron Expression**: Use the `--cron-expression` flag or `BACKUP_CRON_EXPRESSION` environment variable to define the backup schedule. For example, `0 1 * * *` runs the backup daily at 1:00 AM.
|
||||
- **Backup Retention**: Optionally, use the `BACKUP_RETENTION_DAYS` environment variable to automatically delete backups older than a specified number of days.
|
||||
- **S3 Alternatives**: If using an S3 alternative like Minio, set `AWS_DISABLE_SSL="true"` and `AWS_FORCE_PATH_STYLE="true"` as needed.
|
||||
- **S3 Alternatives**: If using an S3 alternative like Minio, set `AWS_DISABLE_SSL=true` and `AWS_FORCE_PATH_STYLE=true` as needed. In the Compose list syntax, do not quote values: the quotes would become part of the value.
|
||||
|
||||
@@ -23,15 +23,16 @@ This section explains how to set up and configure SSH-based backups.
|
||||
3. **Required Environment Variables**
|
||||
The following environment variables are mandatory for SSH-based backups:
|
||||
|
||||
- `SSH_HOST`: The hostname or IP address of the remote server.
|
||||
- `SSH_USER`: The username for SSH authentication.
|
||||
- `SFTP_HOST`: The hostname or IP address of the remote server.
|
||||
- `SFTP_USER`: The username for SSH authentication.
|
||||
- `REMOTE_PATH`: The directory on the remote server where backups will be stored.
|
||||
- `SSH_IDENTIFY_FILE`: The path to the private key file for SSH authentication.
|
||||
- `SSH_PORT`: The SSH port (default is `22`).
|
||||
- `SSH_PASSWORD`: (Optional) Use this only if you are not using a private key for authentication.
|
||||
- `SFTP_IDENTITY_FILE`: The path to the private key file for SSH authentication (`SFTP_IDENTITY_FILE` still works).
|
||||
- `SFTP_KNOWN_HOSTS`: A `known_hosts` file used to verify the server's host key. Host keys are verified by default since v2; `SFTP_INSECURE_IGNORE_HOST_KEY=true` turns the check off (not recommended).
|
||||
- `SFTP_PORT`: The SSH port (default is `22`).
|
||||
- `SFTP_PASSWORD`: (Optional) Use this only if you are not using a private key for authentication.
|
||||
|
||||
{: .note }
|
||||
**Security Recommendation**: Using a private key (`SSH_IDENTIFY_FILE`) is strongly recommended over password-based authentication (`SSH_PASSWORD`) for better security.
|
||||
**Security Recommendation**: Using a private key (`SFTP_IDENTITY_FILE`) is strongly recommended over password-based authentication (`SFTP_PASSWORD`) for better security.
|
||||
|
||||
---
|
||||
|
||||
@@ -54,16 +55,17 @@ services:
|
||||
- DB_PORT=3306
|
||||
- DB_HOST=mysql
|
||||
- DB_NAME=database
|
||||
- DB_USERNAME=username
|
||||
- DB_USER=username
|
||||
- DB_PASSWORD=password
|
||||
## SSH Configuration
|
||||
- SSH_HOST="hostname"
|
||||
- SSH_PORT=22
|
||||
- SSH_USER=user
|
||||
- SFTP_HOST=hostname
|
||||
- SFTP_PORT=22
|
||||
- SFTP_USER=user
|
||||
- REMOTE_PATH=/home/jkaninda/backups
|
||||
- SSH_IDENTIFY_FILE=/tmp/id_ed25519
|
||||
- SFTP_IDENTITY_FILE=/tmp/id_ed25519
|
||||
- SFTP_KNOWN_HOSTS=/config/known_hosts
|
||||
## Optional: Use password instead of private key (not recommended)
|
||||
#- SSH_PASSWORD=password
|
||||
#- SFTP_PASSWORD=password
|
||||
|
||||
# Ensure the mysql-bkup container is connected to the same network as your database
|
||||
networks:
|
||||
@@ -97,18 +99,19 @@ services:
|
||||
- DB_PORT=3306
|
||||
- DB_HOST=postgres
|
||||
- DB_NAME=database
|
||||
- DB_USERNAME=username
|
||||
- DB_USER=username
|
||||
- DB_PASSWORD=password
|
||||
## SSH Configuration
|
||||
- SSH_HOST="hostname"
|
||||
- SSH_PORT=22
|
||||
- SSH_USER=user
|
||||
- SFTP_HOST=hostname
|
||||
- SFTP_PORT=22
|
||||
- SFTP_USER=user
|
||||
- REMOTE_PATH=/home/jkaninda/backups
|
||||
- SSH_IDENTIFY_FILE=/tmp/id_ed25519
|
||||
- SFTP_IDENTITY_FILE=/tmp/id_ed25519
|
||||
- SFTP_KNOWN_HOSTS=/config/known_hosts
|
||||
## Optional: Delete old backups after a specified number of days
|
||||
#- BACKUP_RETENTION_DAYS=7
|
||||
## Optional: Use password instead of private key (not recommended)
|
||||
#- SSH_PASSWORD=password
|
||||
#- SFTP_PASSWORD=password
|
||||
|
||||
# Ensure the mysql-bkup container is connected to the same network as your database
|
||||
networks:
|
||||
@@ -124,6 +127,6 @@ networks:
|
||||
|
||||
- **Cron Expression**: Use the `--cron-expression` flag or `BACKUP_CRON_EXPRESSION` environment variable to define the backup schedule. For example, `0 1 * * *` runs the backup daily at 1:00 AM.
|
||||
- **Backup Retention**: Optionally, use the `BACKUP_RETENTION_DAYS` environment variable to automatically delete backups older than a specified number of days.
|
||||
- **Security**: Always prefer private key authentication (`SSH_IDENTIFY_FILE`) over password-based authentication (`SSH_PASSWORD`) for enhanced security.
|
||||
- **Security**: Always prefer private key authentication (`SFTP_IDENTITY_FILE`) over password-based authentication (`SFTP_PASSWORD`) for enhanced security.
|
||||
|
||||
---
|
||||
@@ -43,7 +43,7 @@ services:
|
||||
- DB_PORT=3306
|
||||
- DB_HOST=mysql
|
||||
- DB_NAME=database
|
||||
- DB_USERNAME=username
|
||||
- DB_USER=username
|
||||
- DB_PASSWORD=password
|
||||
|
||||
# Ensure the mysql-bkup container is connected to the same network as your database
|
||||
@@ -64,7 +64,7 @@ You can also run backups directly using the Docker CLI:
|
||||
docker run --rm --network your_network_name \
|
||||
-v $PWD/backup:/backup/ \
|
||||
-e "DB_HOST=dbhost" \
|
||||
-e "DB_USERNAME=username" \
|
||||
-e "DB_USER=username" \
|
||||
-e "DB_PASSWORD=password" \
|
||||
jkaninda/pg-bkup backup -d database_name
|
||||
```
|
||||
@@ -92,7 +92,7 @@ services:
|
||||
- DB_PORT=3306
|
||||
- DB_HOST=mysql
|
||||
- DB_NAME=database
|
||||
- DB_USERNAME=username
|
||||
- DB_USER=username
|
||||
- DB_PASSWORD=password
|
||||
## Optional: Define a cron schedule for recurring backups
|
||||
- BACKUP_CRON_EXPRESSION=@midnight
|
||||
|
||||
@@ -46,7 +46,7 @@ spec:
|
||||
value: ""
|
||||
- name: DB_NAME
|
||||
value: ""
|
||||
- name: DB_USERNAME
|
||||
- name: DB_USER
|
||||
value: ""
|
||||
# Use Kubernetes Secrets for sensitive data like passwords
|
||||
- name: DB_PASSWORD
|
||||
@@ -104,20 +104,20 @@ spec:
|
||||
value: ""
|
||||
- name: DB_NAME
|
||||
value: "dbname"
|
||||
- name: DB_USERNAME
|
||||
- name: DB_USER
|
||||
value: "postgres"
|
||||
# Use Kubernetes Secrets for sensitive data like passwords
|
||||
- name: DB_PASSWORD
|
||||
value: ""
|
||||
- name: SSH_HOST_NAME
|
||||
- name: SFTP_HOST
|
||||
value: "xxx"
|
||||
- name: SSH_PORT
|
||||
- name: SFTP_PORT
|
||||
value: "22"
|
||||
- name: SSH_USER
|
||||
- name: SFTP_USER
|
||||
value: "xxx"
|
||||
- name: SSH_PASSWORD
|
||||
- name: SFTP_PASSWORD
|
||||
value: "xxxx"
|
||||
- name: SSH_REMOTE_PATH
|
||||
- name: REMOTE_PATH
|
||||
value: "/home/toto/backup"
|
||||
# Optional: Required if you want to encrypt your backup
|
||||
- name: GPG_PASSPHRASE
|
||||
@@ -161,20 +161,20 @@ spec:
|
||||
value: ""
|
||||
- name: DB_NAME
|
||||
value: "dbname"
|
||||
- name: DB_USERNAME
|
||||
- name: DB_USER
|
||||
value: "postgres"
|
||||
# Use Kubernetes Secrets for sensitive data like passwords
|
||||
- name: DB_PASSWORD
|
||||
value: ""
|
||||
- name: SSH_HOST_NAME
|
||||
- name: SFTP_HOST
|
||||
value: "xxx"
|
||||
- name: SSH_PORT
|
||||
- name: SFTP_PORT
|
||||
value: "22"
|
||||
- name: SSH_USER
|
||||
- name: SFTP_USER
|
||||
value: "xxx"
|
||||
- name: SSH_PASSWORD
|
||||
- name: SFTP_PASSWORD
|
||||
value: "xxxx"
|
||||
- name: SSH_REMOTE_PATH
|
||||
- name: REMOTE_PATH
|
||||
value: "/home/toto/backup"
|
||||
# Optional: Required if your backup was encrypted
|
||||
#- name: GPG_PASSPHRASE
|
||||
@@ -220,20 +220,20 @@ spec:
|
||||
value: ""
|
||||
- name: DB_NAME
|
||||
value: "test"
|
||||
- name: DB_USERNAME
|
||||
- name: DB_USER
|
||||
value: "postgres"
|
||||
# Use Kubernetes Secrets for sensitive data like passwords
|
||||
- name: DB_PASSWORD
|
||||
value: ""
|
||||
- name: SSH_HOST_NAME
|
||||
- name: SFTP_HOST
|
||||
value: "192.168.1.16"
|
||||
- name: SSH_PORT
|
||||
- name: SFTP_PORT
|
||||
value: "2222"
|
||||
- name: SSH_USER
|
||||
- name: SFTP_USER
|
||||
value: "jkaninda"
|
||||
- name: SSH_REMOTE_PATH
|
||||
- name: REMOTE_PATH
|
||||
value: "/config/backup"
|
||||
- name: SSH_PASSWORD
|
||||
- name: SFTP_PASSWORD
|
||||
value: "password"
|
||||
# Optional: Required if you want to encrypt your backup
|
||||
#- name: GPG_PASSPHRASE
|
||||
@@ -283,20 +283,20 @@ spec:
|
||||
value: ""
|
||||
- name: DB_NAME
|
||||
value: "test"
|
||||
- name: DB_USERNAME
|
||||
- name: DB_USER
|
||||
value: "postgres"
|
||||
# Use Kubernetes Secrets for sensitive data like passwords
|
||||
- name: DB_PASSWORD
|
||||
value: ""
|
||||
- name: SSH_HOST_NAME
|
||||
- name: SFTP_HOST
|
||||
value: "192.168.1.16"
|
||||
- name: SSH_PORT
|
||||
- name: SFTP_PORT
|
||||
value: "2222"
|
||||
- name: SSH_USER
|
||||
- name: SFTP_USER
|
||||
value: "jkaninda"
|
||||
- name: SSH_REMOTE_PATH
|
||||
- name: REMOTE_PATH
|
||||
value: "/config/backup"
|
||||
- name: SSH_PASSWORD
|
||||
- name: SFTP_PASSWORD
|
||||
value: "password"
|
||||
# Optional: Required if you want to encrypt your backup
|
||||
#- name: GPG_PASSPHRASE
|
||||
@@ -341,7 +341,7 @@ spec:
|
||||
value: "3306"
|
||||
- name: DB_NAME
|
||||
value: "dbname"
|
||||
- name: DB_USERNAME
|
||||
- name: DB_USER
|
||||
value: "username"
|
||||
- name: DB_PASSWORD
|
||||
value: "password"
|
||||
@@ -352,7 +352,7 @@ spec:
|
||||
value: "3306"
|
||||
- name: TARGET_DB_NAME
|
||||
value: "dbname"
|
||||
- name: TARGET_DB_USERNAME
|
||||
- name: TARGET_DB_USER
|
||||
value: "username"
|
||||
- name: TARGET_DB_PASSWORD
|
||||
value: "password"
|
||||
|
||||
@@ -42,7 +42,7 @@ services:
|
||||
- DB_PORT=3306
|
||||
- DB_HOST=mysql
|
||||
- DB_NAME=database
|
||||
- DB_USERNAME=username
|
||||
- DB_USER=username
|
||||
- DB_PASSWORD=password
|
||||
## Required to encrypt backup
|
||||
- GPG_PASSPHRASE=my-secure-passphrase
|
||||
@@ -58,7 +58,7 @@ networks:
|
||||
|
||||
## Using GPG Public Key
|
||||
|
||||
To encrypt backups using a GPG public key, set the `GPG_PUBLIC_KEY` environment variable to the path of your public key file. Backups encrypted with a public key require manual decryption before restoration.
|
||||
To encrypt backups using a GPG public key, set the `GPG_PUBLIC_KEY` environment variable to the path of your public key file. To restore such backups, set `GPG_PRIVATE_KEY` (a file path or the inline armored key; `/config/gnupg/private_key.asc` is picked up automatically) and, if the key is protected, `GPG_PRIVATE_KEY_PASSPHRASE` (defaults to `GPG_PASSPHRASE`).
|
||||
|
||||
### Example Configuration
|
||||
|
||||
@@ -78,7 +78,7 @@ services:
|
||||
- DB_PORT=3306
|
||||
- DB_HOST=mysql
|
||||
- DB_NAME=database
|
||||
- DB_USERNAME=username
|
||||
- DB_USER=username
|
||||
- DB_PASSWORD=password
|
||||
## Required to encrypt backup
|
||||
- GPG_PUBLIC_KEY=/config/public_key.asc
|
||||
@@ -116,5 +116,21 @@ gpg --output database_20240730_044201.sql.gz \
|
||||
## Key Notes
|
||||
|
||||
- **Automatic Restoration**: Backups encrypted with a GPG passphrase can be restored directly without manual decryption.
|
||||
- **Manual Decryption**: Backups encrypted with a GPG public key require manual decryption using the corresponding private key.
|
||||
- **Private key restore**: Backups encrypted with a GPG public key restore directly when `GPG_PRIVATE_KEY` is set; manual decryption also works.
|
||||
- **Fail closed**: if `GPG_PUBLIC_KEY` (or any configured key) cannot be read, the backup fails instead of being stored unencrypted.
|
||||
- **Security**: Always keep your GPG passphrase and private key secure. Use Kubernetes Secrets or other secure methods to manage sensitive data.
|
||||
|
||||
---
|
||||
|
||||
## Using age
|
||||
|
||||
[age](https://age-encryption.org) is a modern alternative to GPG. Set `AGE_RECIPIENTS` (one or more `age1...` or `ssh-ed25519 ...` public keys, comma or newline separated, or `AGE_RECIPIENTS_FILE`) and backups are saved as `.sql.gz.age`. Restore with the matching identity in `AGE_IDENTITY` (`AGE-SECRET-KEY-...`) or `AGE_IDENTITY_FILE` (default `/config/age/identity.txt`).
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
- AGE_RECIPIENTS=age1ql3z7hjy54pw3hyww5ayyfg7zqgvc7w3j2elw8zmrj2kg5sfn9aqmcac8p
|
||||
# restore:
|
||||
# - AGE_IDENTITY_FILE=/run/secrets/age_identity
|
||||
```
|
||||
|
||||
`AGE_PASSPHRASE` encrypts with a passphrase instead (it needs about 256 MiB of memory for the key derivation). `ENCRYPTION=auto|none|gpg|age` chooses explicitly; with `auto` (default) GPG wins when both GPG and age keys are set. Decrypt by hand with `age -d -i key.txt file.sql.gz.age | gunzip`.
|
||||
+10
-7
@@ -45,14 +45,14 @@ services:
|
||||
- DB_PORT=3306
|
||||
- DB_HOST=mysql
|
||||
- DB_NAME=database
|
||||
- DB_USERNAME=username
|
||||
- DB_USER=username
|
||||
- DB_PASSWORD=password
|
||||
|
||||
## Target Database
|
||||
- TARGET_DB_HOST=target-postgres
|
||||
- TARGET_DB_HOST=target-mysql
|
||||
- TARGET_DB_PORT=3306
|
||||
- TARGET_DB_NAME=dbname
|
||||
- TARGET_DB_USERNAME=username
|
||||
- TARGET_DB_USER=username
|
||||
- TARGET_DB_PASSWORD=password
|
||||
|
||||
# Ensure the mysql-bkup container is connected to the same network as your database
|
||||
@@ -78,14 +78,14 @@ Save your source and target database connection details in an environment file (
|
||||
DB_HOST=postgres
|
||||
DB_PORT=3306
|
||||
DB_NAME=dbname
|
||||
DB_USERNAME=username
|
||||
DB_USER=username
|
||||
DB_PASSWORD=password
|
||||
|
||||
## Target Database
|
||||
TARGET_DB_HOST=target-postgres
|
||||
TARGET_DB_HOST=target-mysql
|
||||
TARGET_DB_PORT=3306
|
||||
TARGET_DB_NAME=dbname
|
||||
TARGET_DB_USERNAME=username
|
||||
TARGET_DB_USER=username
|
||||
TARGET_DB_PASSWORD=password
|
||||
```
|
||||
|
||||
@@ -95,12 +95,15 @@ TARGET_DB_PASSWORD=password
|
||||
docker run --rm --network your_network_name \
|
||||
--env-file your-env \
|
||||
-v $PWD/backup:/backup/ \
|
||||
jkaninda/pg-bkup migrate
|
||||
jkaninda/mysql-bkup migrate
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Key Notes
|
||||
|
||||
- **Streaming**: the dump is piped straight into the target server; no file is written. The target database is created if it does not exist, and `TARGET_DB_NAME` defaults to the source name.
|
||||
- **All databases**: `migrate --all-databases` copies every database (system databases excluded, `--exclude-db` / `BACKUP_EXCLUDE_DATABASES` honoured) under the same names.
|
||||
- **MySQL and MariaDB**: source and target may be different flavours; each side uses its own client. Objects that only exist in one flavour (for example MySQL-only collations on old MariaDB versions) can make a cross-flavour migration fail.
|
||||
- **Irreversible Operation**: The `migrate` command directly transfers data from the source to the target database. Ensure you have a backup of the target database before proceeding.
|
||||
- **Network Configuration**: Ensure the `mysql-bkup` container is connected to the same network as your source and target databases.
|
||||
@@ -40,28 +40,28 @@ databases:
|
||||
- host: mysql1 # Optional: Overrides DB_HOST or uses DB_HOST_DATABASE1.
|
||||
port: 3306 # Optional: Default is 5432. Overrides DB_PORT or uses DB_PORT_DATABASE1.
|
||||
name: database1 # Required: Database name.
|
||||
user: database1 # Optional: Overrides DB_USERNAME or uses DB_USERNAME_DATABASE1.
|
||||
user: database1 # Optional: Overrides DB_USER or uses DB_USER_DATABASE1.
|
||||
password: password # Optional: Overrides DB_PASSWORD or uses DB_PASSWORD_DATABASE1.
|
||||
path: /s3-path/database1 # Required: Backup path for SSH, FTP, or S3 (e.g., /home/toto/backup/).
|
||||
|
||||
- host: mysql2 # Optional: Overrides DB_HOST or uses DB_HOST_LLAP.
|
||||
port: 3306 # Optional: Default is 5432. Overrides DB_PORT or uses DB_PORT_LLAP.
|
||||
name: lldap # Required: Database name.
|
||||
user: lldap # Optional: Overrides DB_USERNAME or uses DB_USERNAME_LLAP.
|
||||
user: lldap # Optional: Overrides DB_USER or uses DB_USER_LLAP.
|
||||
password: password # Optional: Overrides DB_PASSWORD or uses DB_PASSWORD_LLAP.
|
||||
path: /s3-path/lldap # Required: Backup path for SSH, FTP, or S3 (e.g., /home/toto/backup/).
|
||||
|
||||
- host: mysql3 # Optional: Overrides DB_HOST or uses DB_HOST_KEYCLOAK.
|
||||
port: 3306 # Optional: Default is 5432. Overrides DB_PORT or uses DB_PORT_KEYCLOAK.
|
||||
name: keycloak # Required: Database name.
|
||||
user: keycloak # Optional: Overrides DB_USERNAME or uses DB_USERNAME_KEYCLOAK.
|
||||
user: keycloak # Optional: Overrides DB_USER or uses DB_USER_KEYCLOAK.
|
||||
password: password # Optional: Overrides DB_PASSWORD or uses DB_PASSWORD_KEYCLOAK.
|
||||
path: /s3-path/keycloak # Required: Backup path for SSH, FTP, or S3 (e.g., /home/toto/backup/).
|
||||
|
||||
- host: mysql4 # Optional: Overrides DB_HOST or uses DB_HOST_JOPLIN.
|
||||
port: 3306 # Optional: Default is 5432. Overrides DB_PORT or uses DB_PORT_JOPLIN.
|
||||
name: joplin # Required: Database name.
|
||||
user: joplin # Optional: Overrides DB_USERNAME or uses DB_USERNAME_JOPLIN.
|
||||
user: joplin # Optional: Overrides DB_USER or uses DB_USER_JOPLIN.
|
||||
password: password # Optional: Overrides DB_PASSWORD or uses DB_PASSWORD_JOPLIN.
|
||||
path: /s3-path/joplin # Required: Backup path for SSH, FTP, or S3 (e.g., /home/toto/backup/).
|
||||
```
|
||||
|
||||
@@ -7,7 +7,7 @@ nav_order: 13
|
||||
|
||||
# Receive Notifications
|
||||
|
||||
You can configure the system to send email or Telegram notifications when a backup succeeds or fails.
|
||||
You can configure the system to send email (SMTP or Posta) or Telegram notifications when a backup succeeds or fails.
|
||||
|
||||
This section explains how to set up and customize notifications.
|
||||
|
||||
@@ -31,7 +31,7 @@ services:
|
||||
- DB_PORT=3306
|
||||
- DB_HOST=mysql
|
||||
- DB_NAME=database
|
||||
- DB_USERNAME=username
|
||||
- DB_USER=username
|
||||
- DB_PASSWORD=password
|
||||
## SMTP Configuration
|
||||
- MAIL_HOST=smtp.example.com
|
||||
@@ -41,7 +41,8 @@ services:
|
||||
- MAIL_FROM=Backup Jobs <backup@example.com>
|
||||
## Multiple recipients separated by a comma
|
||||
- MAIL_TO=me@example.com,team@example.com,manager@example.com
|
||||
- MAIL_SKIP_TLS=false
|
||||
## Only for SMTP servers with a self-signed certificate
|
||||
#- MAIL_INSECURE_SKIP_VERIFY=true
|
||||
## Time format for notifications
|
||||
- TIME_FORMAT=2006-01-02 at 15:04:05
|
||||
## Backup reference (e.g., database/cluster name or server name)
|
||||
@@ -55,6 +56,44 @@ networks:
|
||||
|
||||
---
|
||||
|
||||
## Posta Notifications
|
||||
|
||||
[Posta](https://github.com/goposta/posta) can deliver the notification emails instead of an SMTP server. Set the Posta URL, an API key with the `send` scope and the recipients. By default the same HTML email is sent (with a plain-text version). To use a template stored in Posta instead, set `POSTA_TEMPLATE` (and optionally `POSTA_TEMPLATE_ERROR` for failures); the notification fields (`database`, `file`, `duration`, `storage`, `location`, `size`, `backup_size`, `sha256`, `encryption`, `error`, `time`, `success`, `tool`...) are passed as template data.
|
||||
|
||||
### Example: Posta Notification Configuration
|
||||
|
||||
```yaml
|
||||
services:
|
||||
mysql-bkup:
|
||||
image: jkaninda/mysql-bkup
|
||||
container_name: mysql-bkup
|
||||
command: backup
|
||||
volumes:
|
||||
- ./backup:/backup
|
||||
environment:
|
||||
- DB_PORT=3306
|
||||
- DB_HOST=db
|
||||
- DB_NAME=database
|
||||
- DB_USER=username
|
||||
- DB_PASSWORD=password
|
||||
## Posta
|
||||
- POSTA_URL=https://posta.example.com
|
||||
- POSTA_API_KEY=psk_your_api_key
|
||||
- POSTA_FROM=Backup Jobs <backup@example.com>
|
||||
## Multiple recipients separated by a comma (default MAIL_TO)
|
||||
- POSTA_TO=me@example.com,team@example.com
|
||||
## Optional: templates stored in Posta
|
||||
#- POSTA_TEMPLATE=backup-success
|
||||
#- POSTA_TEMPLATE_ERROR=backup-failure
|
||||
#- POSTA_LANGUAGE=en
|
||||
## Only for account-wide API keys
|
||||
#- POSTA_WORKSPACE_ID=42
|
||||
## Only notify failures
|
||||
#- NOTIFY_ON=failure
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Telegram Notifications
|
||||
|
||||
To send Telegram notifications, provide your bot token and chat ID. Notifications will be sent for both successful and failed backup runs.
|
||||
@@ -73,7 +112,7 @@ services:
|
||||
- DB_PORT=3306
|
||||
- DB_HOST=mysql
|
||||
- DB_NAME=database
|
||||
- DB_USERNAME=username
|
||||
- DB_USER=username
|
||||
- DB_PASSWORD=password
|
||||
## Telegram Configuration
|
||||
- TG_TOKEN=[BOT ID]:[BOT TOKEN]
|
||||
@@ -191,7 +230,7 @@ Backup Reference: {{.BackupReference}}
|
||||
|
||||
## Key Notes
|
||||
|
||||
- **SMTP Configuration**: Ensure your SMTP server supports TLS unless `MAIL_SKIP_TLS` is set to `true`.
|
||||
- **SMTP Configuration**: Ensure your SMTP server supports TLS unless `MAIL_INSECURE_SKIP_VERIFY` is set to `true`. `MAIL_TLS=starttls|tls|none` selects the TLS mode. The 1.x variable `MAIL_SKIP_TLS` is still read with its documented meaning (`true` = skip certificate verification); 1.x had it inverted. Slack (`SLACK_WEBHOOK_URL`), Discord (`DISCORD_WEBHOOK_URL`), ntfy (`NTFY_URL`), generic webhooks (`WEBHOOK_URL`, `WEBHOOK_SECRET`) and healthchecks.io pings (`HEALTHCHECK_PING_URL`) are also available; `NOTIFY_ON=always|failure|success` filters them.
|
||||
- **Telegram Configuration**: Obtain your bot token and chat ID from Telegram.
|
||||
- **Custom Templates**: Mount custom templates to `/config/templates` to override default notifications.
|
||||
- **Time Format**: Use the `TIME_FORMAT` environment variable to customize the timestamp format in notifications.
|
||||
@@ -44,7 +44,7 @@ services:
|
||||
- DB_PORT=3306
|
||||
- DB_HOST=mysql
|
||||
- DB_NAME=database
|
||||
- DB_USERNAME=username
|
||||
- DB_USER=username
|
||||
- DB_PASSWORD=password
|
||||
## AWS S3 Configuration
|
||||
- AWS_S3_ENDPOINT=https://s3.amazonaws.com
|
||||
@@ -56,7 +56,7 @@ services:
|
||||
- AWS_DISABLE_SSL=false
|
||||
## Optional: Enable path-style access for S3 alternatives like Minio
|
||||
- AWS_FORCE_PATH_STYLE=false
|
||||
# Ensure the pg-bkup container is connected to the same network as your database
|
||||
# Ensure the mysql-bkup container is connected to the same network as your database
|
||||
networks:
|
||||
- web
|
||||
|
||||
|
||||
@@ -45,16 +45,17 @@ services:
|
||||
- DB_PORT=3306
|
||||
- DB_HOST=mysql
|
||||
- DB_NAME=database
|
||||
- DB_USERNAME=username
|
||||
- DB_USER=username
|
||||
- DB_PASSWORD=password
|
||||
## SSH Configuration
|
||||
- SSH_HOST_NAME=hostname
|
||||
- SSH_PORT=22
|
||||
- SSH_USER=user
|
||||
- SSH_REMOTE_PATH=/home/jkaninda/backups
|
||||
- SSH_IDENTIFY_FILE=/tmp/id_ed25519
|
||||
- SFTP_HOST=hostname
|
||||
- SFTP_PORT=22
|
||||
- SFTP_USER=user
|
||||
- REMOTE_PATH=/home/jkaninda/backups
|
||||
- SFTP_IDENTITY_FILE=/tmp/id_ed25519
|
||||
- SFTP_KNOWN_HOSTS=/config/known_hosts
|
||||
## Optional: Use password instead of private key (not recommended)
|
||||
#- SSH_PASSWORD=password
|
||||
#- SFTP_PASSWORD=password
|
||||
# Ensure the mysql-bkup container is connected to the same network as your database
|
||||
networks:
|
||||
- web
|
||||
@@ -70,5 +71,5 @@ networks:
|
||||
- **Supported File Formats**: The restore process supports `.sql`, `.sql.gz`, `.sql.gpg`, and `.sql.gz.gpg` files.
|
||||
- **SSH Path**: Use the `--path` flag to specify the folder on the SSH remote server where the backup file is located.
|
||||
- **Encrypted Backups**: If the backup is encrypted with GPG, ensure the `GPG_PASSPHRASE` environment variable is set for automatic decryption.
|
||||
- **SSH Authentication**: Use a private key (`SSH_IDENTIFY_FILE`) for SSH authentication instead of a password for better security.
|
||||
- **SSH Authentication**: Use a private key (`SFTP_IDENTITY_FILE`) for SSH authentication instead of a password for better security. Host keys are verified against `SFTP_KNOWN_HOSTS` (or set `SFTP_INSECURE_IGNORE_HOST_KEY=true`).
|
||||
- **Network Configuration**: Ensure the `mysql-bkup` container is connected to the same network as your database.
|
||||
@@ -45,9 +45,9 @@ services:
|
||||
- DB_PORT=3306
|
||||
- DB_HOST=postgres
|
||||
- DB_NAME=database
|
||||
- DB_USERNAME=username
|
||||
- DB_USER=username
|
||||
- DB_PASSWORD=password
|
||||
# Ensure the pg-bkup container is connected to the same network as your database
|
||||
# Ensure the mysql-bkup container is connected to the same network as your database
|
||||
networks:
|
||||
- web
|
||||
|
||||
|
||||
Reference in new issue
Block a user