Skip to content

Commit 04fd224

Browse files
committed
fix: correct issues in backup-unset-public-key-encryption command
Refs dokku/dokku-postgres#336
1 parent c5203e7 commit 04fd224

File tree

6 files changed

+21
-9
lines changed

6 files changed

+21
-9
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,10 @@ Datastore backups are supported via AWS S3 and S3 compatible services like [mini
504504

505505
You may skip the `backup-auth` step if your dokku install is running within EC2 and has access to the bucket via an IAM profile. In that case, use the `--use-iam` option with the `backup` command.
506506

507+
If both passphrase and public key forms of encryption are set, the public key encryption will take precedence.
508+
509+
The underlying core backup script is present [here](https://github.com/dokku/docker-s3backup/blob/main/backup.sh).
510+
507511
Backups can be performed using the backup commands:
508512

509513
### set GPG Public Key encryption for all future backups of rabbitmq service
@@ -519,6 +523,8 @@ Set the `GPG` Public Key for encrypting backups:
519523
dokku rabbitmq:backup-set-public-key-encryption lollipop
520524
```
521525

526+
This method currently requires the <public-key-id> to be present on the keyserver `keyserver.ubuntu.com`:
527+
522528
### unset GPG Public Key encryption for future backups of the rabbitmq service
523529

524530
```shell

bin/generate

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,10 @@ def usage_backup(
304304
"",
305305
"You may skip the `backup-auth` step if your dokku install is running within EC2 and has access to the bucket via an IAM profile. In that case, use the `--use-iam` option with the `backup` command.",
306306
"",
307+
"If both passphrase and public key forms of encryption are set, the public key encryption will take precedence.",
308+
"",
309+
"The underlying core backup script is present [here](https://github.com/dokku/docker-s3backup/blob/main/backup.sh).",
310+
"",
307311
"Backups can be performed using the backup commands:",
308312
"",
309313
]

common-functions

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ service_backup_set_encryption() {
433433
local SERVICE_ROOT="${PLUGIN_DATA_ROOT}/${SERVICE}"
434434
local SERVICE_BACKUP_ENCRYPTION_ROOT="${SERVICE_ROOT}/backup-encryption/"
435435

436-
mkdir "$SERVICE_BACKUP_ENCRYPTION_ROOT"
436+
mkdir -p "$SERVICE_BACKUP_ENCRYPTION_ROOT"
437437
echo "$ENCRYPTION_KEY" >"${SERVICE_BACKUP_ENCRYPTION_ROOT}/ENCRYPTION_KEY"
438438
}
439439

@@ -443,7 +443,7 @@ service_backup_set_public_key_encryption() {
443443
local SERVICE_ROOT="${PLUGIN_DATA_ROOT}/${SERVICE}"
444444
local SERVICE_BACKUP_ENCRYPTION_ROOT="${SERVICE_ROOT}/backup-encryption/"
445445

446-
mkdir "$SERVICE_BACKUP_ENCRYPTION_ROOT"
446+
mkdir -p "$SERVICE_BACKUP_ENCRYPTION_ROOT"
447447
echo "$ENCRYPT_WITH_PUBLIC_KEY_ID" >"${SERVICE_BACKUP_ENCRYPTION_ROOT}/ENCRYPT_WITH_PUBLIC_KEY_ID"
448448
}
449449

@@ -461,16 +461,16 @@ service_backup_unset_encryption() {
461461
local SERVICE_ROOT="${PLUGIN_DATA_ROOT}/${SERVICE}"
462462
local SERVICE_BACKUP_ENCRYPTION_ROOT="${SERVICE_ROOT}/backup-encryption/"
463463

464-
rm -rf "$SERVICE_BACKUP_ENCRYPTION_ROOT"
464+
rm "$SERVICE_BACKUP_ENCRYPTION_ROOT/ENCRYPTION_KEY"
465465
}
466466

467-
service_backup_unset_encryption() {
468-
declare desc="remove backup encryption"
467+
service_backup_unset_public_key_encryption() {
468+
declare desc="remove backup GPG Public Key encryption"
469469
declare SERVICE="$1"
470470
local SERVICE_ROOT="${PLUGIN_DATA_ROOT}/${SERVICE}"
471471
local SERVICE_BACKUP_ENCRYPTION_ROOT="${SERVICE_ROOT}/backup-encryption/"
472472

473-
rm -rf "$SERVICE_BACKUP_ENCRYPTION_ROOT"
473+
rm "$SERVICE_BACKUP_ENCRYPTION_ROOT/ENCRYPT_WITH_PUBLIC_KEY_ID"
474474
}
475475

476476
service_container_rm() {

subcommands/backup-set-encryption

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
88
service-backup-set-encryption-cmd() {
99
#E set the GPG-compatible passphrase for encrypting backups for backups
1010
#E dokku $PLUGIN_COMMAND_PREFIX:backup-set-encryption lollipop
11+
#E public key encryption will take precendence over the passphrase encryption if both types are set.
1112
#A service, service to run command against
1213
#A passphrase, a GPG-compatible passphrase
1314
declare desc="set encryption for all future backups of $PLUGIN_SERVICE service"

subcommands/backup-set-public-key-encryption

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
88
service-backup-set-public-key-encryption-cmd() {
99
#E set the GPG Public Key for encrypting backups
1010
#E dokku $PLUGIN_COMMAND_PREFIX:backup-set-public-key-encryption lollipop
11+
#E this method currently requires the <public-key-id> to be present on the keyserver 'keyserver.ubuntu.com'
1112
#A service, service to run command against
1213
#A public-key-id, a GPG Public Key ID (or fingerprint) to use for encryption. Must be uploaded to the GPG keyserver beforehand.
1314
declare desc="set GPG Public Key encryption for all future backups of $PLUGIN_SERVICE service"

subcommands/backup-unset-public-key-encryption

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ service-backup-unset-public-key-encryption-cmd() {
1313
local cmd="$PLUGIN_COMMAND_PREFIX:backup-unset-public-key-encryption" argv=("$@")
1414
[[ ${argv[0]} == "$cmd" ]] && shift 1
1515
declare SERVICE="$1"
16-
is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" # TODO: [22.03.2024 by Mykola]
16+
is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented"
1717

1818
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service"
1919
verify_service_name "$SERVICE"
20-
service_backup_unset_public_key_encryption "$SERVICE" # TODO: [22.03.2024 by Mykola]
20+
service_backup_unset_public_key_encryption "$SERVICE"
2121
}
2222

23-
service-backup-unset-encryption-cmd "$@"
23+
service-backup-unset-public-key-encryption-cmd "$@"

0 commit comments

Comments
 (0)