fix: fix database migration
This commit is contained in:
@@ -6,14 +6,20 @@ nav_order: 8
|
||||
---
|
||||
# Encrypt backup
|
||||
|
||||
The image supports encrypting backups using one of two available methods: GPG with passphrase or GPG with a public key
|
||||
|
||||
## Using GPG passphrase
|
||||
|
||||
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 }
|
||||
To restore an encrypted backup, you need to provide the same GPG passphrase used during backup process.
|
||||
Or
|
||||
|
||||
- GPG home directory `/config/gnupg`
|
||||
- Cipher algorithm `aes256`
|
||||
-
|
||||
|
||||
|
||||
To decrypt manually, you need to install `gnupg`
|
||||
|
||||
```shell
|
||||
@@ -50,3 +56,4 @@ services:
|
||||
networks:
|
||||
web:
|
||||
```
|
||||
## Using GPG public key
|
||||
|
||||
@@ -35,7 +35,7 @@ Backup, restore and migrate targets, schedule and retention are configured using
|
||||
## Environment variables
|
||||
|
||||
| Name | Requirement | Description |
|
||||
|------------------------|---------------------------------------------------------------|------------------------------------------------------|
|
||||
|------------------------|---------------------------------------------------------------|-----------------------------------------------------------------|
|
||||
| DB_PORT | Optional, default 5432 | Database port number |
|
||||
| DB_HOST | Required | Database host |
|
||||
| DB_NAME | Optional if it was provided from the -d flag | Database name |
|
||||
@@ -50,6 +50,7 @@ Backup, restore and migrate targets, schedule and retention are configured using
|
||||
| AWS_FORCE_PATH_STYLE | Optional, required for S3 storage | Force path style |
|
||||
| FILE_NAME | Optional if it was provided from the --file flag | Database file to restore (extensions: .sql, .sql.gz) |
|
||||
| GPG_PASSPHRASE | Optional, required to encrypt and restore backup | GPG passphrase |
|
||||
| GPG_PUBLIC_KEY | Optional, required to encrypt backup | GPG public key, used to encrypt backup (/config/public_key.asc) |
|
||||
| BACKUP_CRON_EXPRESSION | Optional if it was provided from the `--cron-expression` flag | Backup cron expression for docker in scheduled mode |
|
||||
| SSH_HOST | Optional, required for SSH storage | ssh remote hostname or ip |
|
||||
| SSH_USER | Optional, required for SSH storage | ssh remote user |
|
||||
|
||||
@@ -71,6 +71,7 @@ func RestoreDatabase(db *dbConfig, conf *RestoreConfig) {
|
||||
if extension == ".gpg" {
|
||||
|
||||
if conf.usingKey {
|
||||
utils.Warn("Backup decryption using a private key is not fully supported")
|
||||
err := decrypt(filepath.Join(tmpPath, conf.file), conf.privateKey, conf.passphrase)
|
||||
if err != nil {
|
||||
utils.Fatal("Error during decrypting backup %v", err)
|
||||
@@ -116,7 +117,7 @@ func RestoreDatabase(db *dbConfig, conf *RestoreConfig) {
|
||||
|
||||
} else if extension == ".sql" {
|
||||
//Restore from sql file
|
||||
str := "cat " + filepath.Join(tmpPath, file) + " | psql -h " + db.dbHost + " -p " + db.dbPort + " -U " + db.dbUserName + " -v -d " + db.dbName
|
||||
str := "cat " + filepath.Join(tmpPath, conf.file) + " | psql -h " + db.dbHost + " -p " + db.dbPort + " -U " + db.dbUserName + " -v -d " + db.dbName
|
||||
_, err := exec.Command("sh", "-c", str).Output()
|
||||
if err != nil {
|
||||
utils.Fatal("Error in restoring the database %v", err)
|
||||
|
||||
Reference in New Issue
Block a user