-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Allow for specifying the S3 Storage Class #205
base: master
Are you sure you want to change the base?
Changes from 9 commits
565ad35
05da386
347195c
6c09e3d
812619d
001dff3
6b96fdd
114593b
3e78949
a212e19
b6325b4
5e2662e
1d027ba
b820322
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,6 +176,7 @@ service_backup() { | |
local BACKUP_ENCRYPTION_CONFIG_ROOT="$PLUGIN_DATA_ROOT/$SERVICE/backup-encryption" | ||
local AWS_ACCESS_KEY_ID_FILE="$SERVICE_BACKUP_ROOT/AWS_ACCESS_KEY_ID" | ||
local AWS_SECRET_ACCESS_KEY_FILE="$SERVICE_BACKUP_ROOT/AWS_SECRET_ACCESS_KEY" | ||
local S3_STORAGE_CLASS_FILE="$SERVICE_BACKUP_ROOT/S3_STORAGE_CLASS" | ||
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE" | ||
local ID="$(cat "$SERVICE_ROOT/ID")" | ||
local BACKUP_PARAMETERS="" | ||
|
@@ -188,6 +189,10 @@ service_backup() { | |
dokku_log_fail "Provide AWS credentials or use the --use-iam flag" | ||
fi | ||
|
||
if [[ -f "$S3_STORAGE_CLASS_FILE" ]]; then | ||
BACKUP_PARAMETERS="$BACKUP_PARAMETERS -e S3_STORAGE_CLASS=$(cat "$S3_STORAGE_CLASS_FILE")" | ||
fi | ||
|
||
TMPDIR=$(mktemp -d --tmpdir) | ||
trap 'rm -rf "$TMPDIR" > /dev/null' RETURN INT TERM EXIT | ||
|
||
|
@@ -226,7 +231,7 @@ service_backup_auth() { | |
declare SERVICE="$1" AWS_ACCESS_KEY_ID="$2" AWS_SECRET_ACCESS_KEY="$3" AWS_DEFAULT_REGION="$4" AWS_SIGNATURE_VERSION="$5" ENDPOINT_URL="$6" | ||
local SERVICE_BACKUP_ROOT="$PLUGIN_DATA_ROOT/$SERVICE/backup" | ||
|
||
mkdir "$SERVICE_BACKUP_ROOT" | ||
mkdir -p "$SERVICE_BACKUP_ROOT" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Otherwise it will fail upon trying to create the dir if it already existed |
||
echo "$AWS_ACCESS_KEY_ID" >"$SERVICE_BACKUP_ROOT/AWS_ACCESS_KEY_ID" | ||
echo "$AWS_SECRET_ACCESS_KEY" >"$SERVICE_BACKUP_ROOT/AWS_SECRET_ACCESS_KEY" | ||
|
||
|
@@ -249,7 +254,22 @@ service_backup_deauth() { | |
local SERVICE_ROOT="${PLUGIN_DATA_ROOT}/${SERVICE}" | ||
local SERVICE_BACKUP_ROOT="${SERVICE_ROOT}/backup/" | ||
|
||
rm -rf "$SERVICE_BACKUP_ROOT" | ||
rm -f "$SERVICE_BACKUP_ROOT/AWS_ACCESS_KEY_ID" | ||
rm -f "$SERVICE_BACKUP_ROOT/AWS_SECRET_ACCESS_KEY" | ||
rm -f "$SERVICE_BACKUP_ROOT/AWS_DEFAULT_REGION" | ||
rm -f "$SERVICE_BACKUP_ROOT/AWS_SIGNATURE_VERSION" | ||
rm -f "$SERVICE_BACKUP_ROOT/ENDPOINT_URL" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the auth command is no longer the only one using that directory, leaving it the way it was would also delete the S3_STORAGE_CLASS. |
||
|
||
} | ||
|
||
service_backup_s3class() { | ||
declare desc="Sets the S3 storage class to be used for the backup" | ||
declare SERVICE="$1" S3_STORAGE_CLASS="$2" | ||
local SERVICE_BACKUP_ROOT="$PLUGIN_DATA_ROOT/$SERVICE/backup/" | ||
|
||
mkdir -p "$SERVICE_BACKUP_ROOT" | ||
echo "$S3_STORAGE_CLASS" >"$SERVICE_BACKUP_ROOT/S3_STORAGE_CLASS" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I really need to transfer all of this to the new properties system... |
||
|
||
} | ||
|
||
service_backup_schedule() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config" | ||
set -eo pipefail | ||
[[ $DOKKU_TRACE ]] && set -x | ||
source "$PLUGIN_BASE_PATH/common/functions" | ||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" | ||
|
||
service-backup-s3class-cmd() { | ||
#E set the s3 storage class to Standard Infrequent Access | ||
#E dokku $PLUGIN_COMMAND_PREFIX:backup-s3class lolipop STANDARD_IA | ||
#A service, service to run command against | ||
#A storage-class, an aws S3 storage class | ||
declare desc="sets the S3 storage class to be used for backups on the $PLUGIN_SERVICE service" | ||
local cmd="$PLUGIN_COMMAND_PREFIX:backup-s3class" argv=("$@") | ||
[[ ${argv[0]} == "$cmd" ]] && shift 1 | ||
declare SERVICE="$1" S3_STORAGE_CLASS="$2" | ||
is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented" | ||
|
||
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" | ||
[[ -z "$S3_STORAGE_CLASS" ]] && dokku_log_fail "Please specify an aws S3 storage class" | ||
[[ ! "$S3_STORAGE_CLASS" =~ ^(STANDARD|REDUCED_REDUNDANCY|STANDARD_IA|ONEZONE_IA|INTELLIGENT_TIERING|GLACIER|DEEP_ARCHIVE)$ ]] && dokku_log_fail "$S3_STORAGE_CLASS is not a valid S3 storage class. Read https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html for more information." | ||
service_backup_s3class "$SERVICE" "$S3_STORAGE_CLASS" | ||
} | ||
|
||
service-backup-s3class-cmd "$@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you manually regenerate the readme via
make README.md
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the way it generates, I can fix the output but idk if there's an issue with the parsing or my subcommand.