-
-
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 all 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 |
---|---|---|
|
@@ -3,6 +3,7 @@ source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config" | |
set -eo pipefail | ||
[[ $DOKKU_TRACE ]] && set -x | ||
source "$PLUGIN_AVAILABLE_PATH/config/functions" | ||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions" | ||
|
||
docker_ports_options() { | ||
declare desc="Exports a list of exposed ports" | ||
|
@@ -188,6 +189,10 @@ service_backup() { | |
dokku_log_fail "Provide AWS credentials or use the --use-iam flag" | ||
fi | ||
|
||
if fn-plugin-property-exists "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "S3_STORAGE_CLASS"; then | ||
BACKUP_PARAMETERS="$BACKUP_PARAMETERS -e S3_STORAGE_CLASS=$(fn-plugin-property-get "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "S3_STORAGE_CLASS")" | ||
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" | ||
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,18 @@ 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" | ||
fn-plugin-property-write "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "S3_STORAGE_CLASS" "$S3_STORAGE_CLASS" | ||
} | ||
|
||
service_backup_schedule() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/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" 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 "$STORAGE_CLASS" ]] && dokku_log_fail "Please specify an aws S3 storage class" | ||
[[ ! "$STORAGE_CLASS" =~ ^(STANDARD|REDUCED_REDUNDANCY|STANDARD_IA|ONEZONE_IA|INTELLIGENT_TIERING|GLACIER|DEEP_ARCHIVE)$ ]] && dokku_log_fail "$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" "$STORAGE_CLASS" | ||
echo "Set the storage class to $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.
Was this necessary?
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.
Otherwise it will fail upon trying to create the dir if it already existed