mirror of
https://github.com/jkaninda/mysql-bkup.git
synced 2025-12-08 06:29:41 +01:00
chore: define gpg home directory
This commit is contained in:
@@ -9,8 +9,11 @@ nav_order: 7
|
|||||||
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.
|
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.
|
||||||
|
|
||||||
{: .warning }
|
{: .warning }
|
||||||
To restore an encrypted backup, you need to provide the same GPG passphrase used during backup process.
|
To restore an encrypted backup, you need to provide the same GPG passphrase or key used during backup process.
|
||||||
|
|
||||||
|
- GPG home directory `/config/gnupg`
|
||||||
|
- Cipher algorithm `aes256`
|
||||||
|
-
|
||||||
To decrypt manually, you need to install `gnupg`
|
To decrypt manually, you need to install `gnupg`
|
||||||
|
|
||||||
### Decrypt backup
|
### Decrypt backup
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ Backup, restore and migrate targets, schedule and retention are configured using
|
|||||||
## Environment variables
|
## Environment variables
|
||||||
|
|
||||||
| Name | Requirement | Description |
|
| Name | Requirement | Description |
|
||||||
|------------------------|----------------------------------------------------|------------------------------------------------------|
|
|------------------------|--------------------------------------------------------------|------------------------------------------------------|
|
||||||
| DB_PORT | Optional, default 3306 | Database port number |
|
| DB_PORT | Optional, default 3306 | Database port number |
|
||||||
| DB_HOST | Required | Database host |
|
| DB_HOST | Required | Database host |
|
||||||
| DB_NAME | Optional if it was provided from the -d flag | Database name |
|
| DB_NAME | Optional if it was provided from the -d flag | Database name |
|
||||||
@@ -48,7 +48,7 @@ Backup, restore and migrate targets, schedule and retention are configured using
|
|||||||
| AWS_REGION | Optional, required for S3 storage | AWS Region |
|
| AWS_REGION | Optional, required for S3 storage | AWS Region |
|
||||||
| AWS_DISABLE_SSL | Optional, required for S3 storage | Disable SSL |
|
| AWS_DISABLE_SSL | Optional, required for S3 storage | Disable SSL |
|
||||||
| FILE_NAME | Optional if it was provided from the --file flag | Database file to restore (extensions: .sql, .sql.gz) |
|
| FILE_NAME | Optional if it was provided from the --file flag | Database file to restore (extensions: .sql, .sql.gz) |
|
||||||
| BACKUP_CRON_EXPRESSION | Optional if it was provided from the --period flag | Backup cron expression for docker in scheduled mode |
|
| BACKUP_CRON_EXPRESSION | Optional if it was provided from the --cron-expression flag | Backup cron expression for docker in scheduled mode |
|
||||||
| GPG_PASSPHRASE | Optional, required to encrypt and restore backup | GPG passphrase |
|
| GPG_PASSPHRASE | Optional, required to encrypt and restore backup | GPG passphrase |
|
||||||
| SSH_HOST_NAME | Optional, required for SSH storage | ssh remote hostname or ip |
|
| SSH_HOST_NAME | Optional, required for SSH storage | ssh remote hostname or ip |
|
||||||
| SSH_USER | Optional, required for SSH storage | ssh remote user |
|
| SSH_USER | Optional, required for SSH storage | ssh remote user |
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
func Decrypt(inputFile string, passphrase string) error {
|
func Decrypt(inputFile string, passphrase string) error {
|
||||||
utils.Info("Decrypting backup file: " + inputFile + " ...")
|
utils.Info("Decrypting backup file: " + inputFile + " ...")
|
||||||
//Create gpg home dir
|
//Create gpg home dir
|
||||||
err := utils.MakeDir(gpgHome)
|
err := utils.MakeDirAll(gpgHome)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ func Decrypt(inputFile string, passphrase string) error {
|
|||||||
func Encrypt(inputFile string, passphrase string) error {
|
func Encrypt(inputFile string, passphrase string) error {
|
||||||
utils.Info("Encrypting backup...")
|
utils.Info("Encrypting backup...")
|
||||||
//Create gpg home dir
|
//Create gpg home dir
|
||||||
err := utils.MakeDir(gpgHome)
|
err := utils.MakeDirAll(gpgHome)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const cronLogFile = "/var/log/mysql-bkup.log"
|
|||||||
const tmpPath = "/tmp/backup"
|
const tmpPath = "/tmp/backup"
|
||||||
const backupCronFile = "/usr/local/bin/backup_cron.sh"
|
const backupCronFile = "/usr/local/bin/backup_cron.sh"
|
||||||
const algorithm = "aes256"
|
const algorithm = "aes256"
|
||||||
const gpgHome = "gnupg"
|
const gpgHome = "/config/gnupg"
|
||||||
const gpgExtension = "gpg"
|
const gpgExtension = "gpg"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
Reference in New Issue
Block a user